I am working on this program for an assignment and I cant figure out how to get it to work. I am not asking to do my homework just assistance. I have some to find a number odd or even and then put it through a recurrence relation.
.........{ 0 if n=0
f(n)= { f(1/2n) if n is even, n > 0
.........{1+f(n-1) if n is odd, n > 0
So what i figured was that i can find if the number that the user entered is odd or even by running it through a function and then put that number through the even or odd function. When i run the program i just get 0,0 for any number. I know something isnt right but i cant just find it.
It is not clear whether function Odd shall calculate the sum of kind 1 + 1 +...+ 1 or n + n-1 + n-2+...+1. In any case your function is incorrect because instead of the comparision operator == you use the assignment operator =