Question: in c++ Write a program that takes a positive integer n, and prints the sequence as explained below, If n is a multiple of 3,

in c++in c++ Write a program that takes a positive integer n, and

Write a program that takes a positive integer n, and prints the sequence as explained below, If n is a multiple of 3, then the next value in the sequence is n-1. Otherwise, the next value in the sequence is n/2 (integer division). The sequence continues until n is positive. Please note that the sequence should not contain any negative values or 0. Make sure your program validates the user input. For invalid inputs, print "Invalid input." For example: Test Input Result // test case example 1 13 Enter a positive number: 13 6 5 2 1 // test case example 2 -10 Enter a positive number: Invalid input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!