In order to avoid problem for us I won't give you direct answer. I will just discuss about in term of math. Look at the problem:
- if even number then do: n/2
- if odd number then do: 3*n+1; however, 3*n+1 = n/2 + 5/2*n + 1.
So we can rewrite the problem as:
- if even number then do: n/2 + (5/2*n + 1) * 0;
- if odd number then do: n/2 + (5/2*n + 1) * 1;
To know when will we multiply the remain part with 0 or 1: you can use modulo function.
Grangle!!!