My recursive function needs to calculate the power of high b to N is giving error of "Segmentation fault (recorded core image)", what can be?
My role:
int potencia(int b, int n, int a){
if(n == 0){
return b;
}
b=b*a;
return potencia(b,n-1,a);
}
int main(){
int a,b,pot,n;
printf("Informe um valor b: ");
scanf("%d",&b);
printf("Informe um valor expo: ");
scanf("%d",&expo);
a=b;
pot=potencia(b,expo,a);
printf("%d\n",pot);
return 0;
}