- Impact
- 19
Hey
I am trying to figure out how to do this
I need to make a recursive function which does
b^e = b*b^e-1
so far..i have a function that will just compute b^e
This is in C by the way...but do it in PHP or any other language...i just need to know how to do this..i can translate it into C
heres the code for just b^e
Thanks
I am trying to figure out how to do this
I need to make a recursive function which does
b^e = b*b^e-1
so far..i have a function that will just compute b^e
This is in C by the way...but do it in PHP or any other language...i just need to know how to do this..i can translate it into C
heres the code for just b^e
Code:
#include<stdio.h>
int intPow(int b,int e); /*Function prototype*/
int main(){
int b,e;
printf("Please enter two integers: ");
scanf("%d%d",&b,&e);
printf("%d to the power of %d is %d\n",b,e,intPow(b,e));
}
int intPow(int b,int e){
int power = 1;
for(int i=1;i<=e;i++){
power *= b;
}
return power;
}
Thanks







