Consider an iterative procedure that begins with a positive integer N0 and generates a sequence by the
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 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:
- if any term in the sequence equals 1, then all successive terms are 1
- if any term in the sequence equals 58, then the sequence cycles:
..., 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145.....
- It is known that either condition a or b MUST occur.
- 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