Skip to content

Instantly share code, notes, and snippets.

@kishaningithub
Created March 21, 2014 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kishaningithub/9685038 to your computer and use it in GitHub Desktop.
Save kishaningithub/9685038 to your computer and use it in GitHub Desktop.
Recurse_Pow
#include <stdio.h>
main()
{
printf("%d",pow_recurse(3,300));
}
int pow_recurse(int base,int power)
{
int temp;
if(power==1){
return base;
}else{
temp=pow_recurse(base,power/2);
if(power%2==0){
return temp*temp;
}else{
return temp*temp*base;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment