Question: Consider an iterative procedure that begins with a positive integer N0 and generates a sequence by the rule: Ni +1 = the sum of the

Consider an iterative procedure that begins with a positive integer N0 and generates a sequence by the rule:

Ni +1 = the sum of the squares of the digits of Ni

For example, if you begin with 25 the sequence is

25

29 (since 29 = 22 + 52)

85 (since 85 = 22 + 92)

89 (89 = 82 + 52) etc.

Rules:

  1. if any term in the sequence equals 1, then all successive terms are 1
  2. if any term in the sequence equals 58, then the sequence cycles:

..., 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145.....

    1. It is known that either condition a or b MUST occur.
    2. An integer N0 is called insipid if condition (a) occurs.

Write a program to test for insipid ints between 1 and 99.

Your program will prompt the user for a number from 1 to 99. Itwill then print out the sequence as described above and tell whether the number is insipid or not.

Sample Input/Output

Example #1:

Please enter an int 1 - 99 (inclusive) : 2

The sequence starting at 2 is: 2 4 16 37 58 The number is: Not insipid

Example #2:

Please enter an int 1 - 99 (inclusive) : 13

The sequence starting at 13 is: 13 10 1 The number is: Insipid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the logic breakdown Function to check insipid Define a function isinsipidnumber that takes an ... View full answer

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 Programming Questions!