C++ program 0) as follows:If n is 1, stop.If n is even, the next number is n/2.If n is odd, the next number is 3*n + 1.Continue with this process until reaching 1.Here are some examples for the...


C++ program


1. A mathematical generating a sequence of numbers from any positive integer n<br>(n > 0) as follows:<br>If n is 1, stop.<br>If n is even, the next number is n/2.<br>If n is odd, the next number is 3*n + 1.<br>Continue with this process until reaching 1.<br>Here are some examples for the first few integers.<br>2 -><br>3 -> 10 -><br>5 -> 16 -><br>8 -><br>4 -><br>2 -><br>1<br>4<br>2 -><br>5 -> 16 -><br>8 -><br>4 -><br>2 -><br>1<br>6 -><br>7 -> 22<br>5 above.<br>3 -> etc as for 3<br>ー> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 -> see<br>above.<br>Do you want to try again? (y/n):<br>Write a program that reads a number and prints the mathematical sequence for it.<br>

Extracted text: 1. A mathematical generating a sequence of numbers from any positive integer n (n > 0) as follows: If n is 1, stop. If n is even, the next number is n/2. If n is odd, the next number is 3*n + 1. Continue with this process until reaching 1. Here are some examples for the first few integers. 2 -> 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 4 2 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 6 -> 7 -> 22 5 above. 3 -> etc as for 3 ー> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 -> see above. Do you want to try again? (y/n): Write a program that reads a number and prints the mathematical sequence for it.

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here