Computer Science, asked by sandycrazyfun, 2 months ago

We start with a two-digit positive integer and construct a sequence of two-digit numbers as follows. Let the current number be x. If 2x is less than 100, then the next number in the sequence is 2x. Otherwise, the next number in the sequence is 2*x − 100.



A number is said to be good if we can start with the number and get back to the same number later in the sequence. A number is said to be bad if it is not good!



For example:

20 is a good number, because the sequence starting with 20 is 20, 40, 80, 60, 20. So, after four steps, we get back to 20.
10 is bad because starting from 10 we get the sequence 10, 20, 40, 80, 60, 20, . . . in which 10 never appears again.


Write a program that takes the value of positive integer N and outputs the sum of the first N good numbers.



Constraints:

0 < N < 20

Answers

Answered by DarksiteGaming
0

Answer:

For (i=1;i<N+1;i++)

cout<<”\n”<<2*i;

Disclaimer: I am a civil engineering. I don't know programming at all.

Similar questions