Question: C++ : Write a recursive function called hailstone (int n) that take an integer n as parameter. If n is odd, the function should update
C++ : Write a recursive function called hailstone (int n) that take an integer n as parameter. If n is odd, the function should update the value of n by multiplying it by 3 and adding 1. If n is even, the function should update the value of n by dividing it by 2. The process is repeated until the value of n becomes equal to 1. Further, hailstone () should print the updated values of n and return the number of steps.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
