This is done by using exponential theory :-
I am giving my code here for a^b int power (int a,int b) { int x=1,y=a; while(b>0) { if(b%2==1) x=(x*y) if (b/=2) y=(y*y); } return x; } Run time O(log b) -- 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?hl=en.