# In C++, write a method that follows the Collatz conjecture. If n is even set n=n/2 and if n is odd set n=3n+1.

# Question

The Collatz conjecture states that when taking any natural number n, if n is even, set n = n /2. If n is odd, set n = 3n + 1. Repeat this process until n is equal to 1. The conjecture states that no matter what number you start with, you will always reach 1.

# Explanation

Create a while loop where it will exit out of the loop once n is equal to 1. It will keep iterating in…