How to I make a recursive version of this function?
Code:
I tried to, but the cmd crashes for some reason:
Code:
Code:
int Exp(int n, int a)
{
int i, res = 0;
for (i=1 ; i<=n; i++)
res+=( a+i/n)*(a+i/n);
return res;
}
I tried to, but the cmd crashes for some reason:
Code:
#include <stdio.h>
int func ( int x, int n);
int func ( int x, int n)
{
int i;
for ( i=0; i>=n; i++)
x*= x;
return x;
}
int *Exp ( int a, int n, int i)
{
int *ptr;
if (i>n)
return (*ptr = 0);
else
{
Exp ( a, n, i++);
*ptr += func( (a+(i/n)), 2);
return *ptr;
}
}
main()
{
printf ( "%d \n", *Exp ( 5, 10, 1) );
}