Potęga liczby – rekurencja
Oby dwie liczby są zainicjowane w programie (na przykładzie 3,2).
Kompilator: Dev C++
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
double potega(double a, int n)
{
if (n==0)return 1;
return a*potega(a,n-1);
}
int main(int argc, char *argv[])
{
cout<<potega(3,2)<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}