ReignMan
asked on
Help Writing a Recursive Function
Help, i need to write a recursive function showing that the Sumation of (k-1)/2^k = 0 when k is from 0 to infinity.
hope this makes sense, if not let me know
thanks!
hope this makes sense, if not let me know
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
whoa, completely ignore my ignorance, i didnt see his much MUCH better answer. Props to burtday
#include <stdio.h>
#include <iostream.h>
int a = 0;
int k = 0;
double c;
double r = 0;
double f = 0;
int g = 0;
int p = 0;
int b = 0;
float ans;
void main()
{
FILE * pFile;
pFile = fopen ("myfile.txt","w");
loop1:
{
while(b <= f)
{
if (p = 0)
{
r = 2 * 2;
p = p++;
}
if (p != 0)
{
r = r * 2;
p = p++;
}
b = b++;
}
c = (k-1);
g = (2^k);
ans = c/g;
fprintf (pFile, "Variable k being %d resulted in %f\n",k,ans);
k = k++;
f = f++;
r = 0;
b = 0;
p = 0;
goto loop1;
}
fclose (pFile);
}
The answers that come out look sorta funny to me, but as I said, Im not a math guy, if it doesnt work, just tell me any I'll try to help you further. Good luck.