Hi I am writing a program that prompts the user to write a positive integer N and then computes S(N) = the sum from k=1 to N of H(k) and reports this values.
For every number n, H(n) denotes the number of time required to get an output of 1 by repeatedly applying the function f(n).
f(n) is defined as:
if n is even: n/2
if n is odd: 3n+1
To get a value of 1, I must apply f as many times as necessary, for example H(7) = 16.
This is more complicated than anything I have done before and I am trying to read up on recursion. I know the attached code is wrong. I am wondering if I have to call a function and how to incorporate returning a value for H(k).