You can also do it in O(log2(log3(N))) by implementing binary search
for power of 3 !
but its slower than normal way for small N's !

On Sep 21, 8:22 pm, Anshya Aggarwal <anshya.aggar...@gmail.com> wrote:
> how to find that whether the given number was of the form 3^n. ( i.e. 3 to
> the power n).
> one way is to recursively divide the number by 3 and check the remainder.
> Is there any other way using bit manipulation or anything else??
>
> --
> Anshya Aggarwal

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to