Notes to myself: Best practices in CS
Saturday, 12 April 2014
Fast Expontiation iterative version
long pow(long a, long x)
{
long res = 1;
while(x>0){
if(x%2!=0)
{
res = res* a;
}
x = x/2;
a = a*a;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment