Okay, your function parameters are all wrong. You cannot do calculations tehre, you can only put parameters in seperated by commas (int myFunc (int a, int b)).
Your vulgar language is another thing...
You never call your function from anywhere in the program, thereby making it useless.
OO sorry for the vulgar language. If u mean my grammar sucks, then ok... i'll try to improve that. If you are pointing out i did not show any gratitude then i am really sorry i will be more polite.
So back to the question, yes i know you cannot pass a +2 in the function at the beginning. So the actually question is how to approach to write a recursion of x(n+2) = (10/3) * X(n+1) - Xn for x0 = 1 x1 = 1/3?
I can simplify the function by solving it and it will end up Xn = (1/3)^n but i just want to know is there a way to code x(n+2) = (10/3) * X(n+1) - Xn for x0 = 1 x1 = 1/3 instead. S=.
#include <iostream>
usingnamespace std;
double x;
double function (x )
{
if (x ==-2)
return 1;
if (x== -1)
return (1/3);
elsereturn ( (10/3)*function(x-1) - function(x-2));
}
int main()
{
double y;
cout<<"type in the number";
cin>>y;
}
yea i tried the above and it give me some strange numbers that i wasn't expecting. e.g i put in (1) it give me 0 S=. So it seems that's how i should be doing it, then how to set my initial conditio where x0 = 1 x1 = 1/3?