DennisFoc98
Grünschnabel
Hallo, Leute. Ich verstehe den output meiner Funktion nicht. Der output ist 81 . Wie rechner der Computer das? Ich komme auf 78.
Code:
#include <iostream>
using namespace std;
int exponent(int basis,int exp)
{
if(exp==5)
{
return 1;
}
else
{
return basis* exponent(basis,exp+1);
/* 3(3,2) = 9+6=15
* 3(3,3) = 9+9=18
* 3(3,4) = 9+12=21
* 3(3,5) = 9+15=24
* total= 78;*/ <-----------------
}
}
int main()
{
cout<<exponent(3,1);
}