f(n) = 3n + 1, if n is odd ; and
f(n) = n/2, if n is even
Use a random number generator to generate a number between 1 and 100 and pass it through
the above function. The function keeps calling itself recursively until the value of n
becomes 1.
Simulate the above operation for 50 times. Each time make a note of how many times
the odd condition of the function was executed and how many times the even condition
of the function was executed.
Create three files, that will save the following information for each 50 simulations
of the above function,
1. the value of 'n'
2. the number of odd operations performed
3. the number of even operations performed
--------------------------------
I am unsure exactly what this is wanting- what it should do, how to start...
@jasonwynn10, I ran the code, however it seems to me like it is just generating a bunch of random numbers until it hits 1, and then it stops and tells how many times it ran. I think it is supposed to generate a random number, decide if it is even or odd, run the respective function on it, and then keep doing that until it finally gets to 1. Then it should do that whole process again 50 times. After that, it needs to tell the user, of the 50 times it ran, show the values of n, tell how many times an even function was performed and tell how many times an odd function was performed.
For example:
#
#
#
#
#
#
1
Odd functions performed: _____
Even functions performed: _____
If you have any ideas on how we can tinker with the code you posted, let me know; and thanks again for the help, I really appreciate it!