just a thought , if you want to calculate specifically power(n,n)
then it can be done simply by bit-wise operation

power(n,n)
    a=ceil(n/2);
    return a << n;

On Tue, May 15, 2012 at 8:28 AM, pankaj joshi <joshi10...@gmail.com> wrote:

> Hi All,
>
> I have written a program to find out n^n(n power n),
>
> long long unsigned int power(int n, int i)
> {
> if(i == 1)
>  {
> return n;
> }
>  else
> {
> if(i%2 != 1)
>  {
> long long unsigned int mul;
> mul = power(n,i/2);
>  return mul*mul;
> }
> else
>  {
> return (power(n,i-1)*n);
> }
>  }
> }
>
> This program is working fine for power(15,15), but it is overflow for
> power(16,16), as long long unsigned int is 2^64.
>
> Please tell me how to store the values more than 2^64,
> i had thing to store in array.
> Please suggest me .
>
> thanks ..
>
> --
>  Regards,
>
> Pankaj Kumar Joshi
>
> --
> 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.
>

-- 
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.

Reply via email to