Question: Done in Java. Any help greatly appreciated! Note: No arrays or any other data structure (arraylist, hashmap, sets, linkedlist, stacks, queue) is allowed Hint: You

Done in Java. Any help greatly appreciated!

Note: No arrays or any other data structure (arraylist, hashmap, sets, linkedlist, stacks, queue) is allowed

Hint: You may want to read inpurs as positive integers and provide results in String.

Write a java program to determine whether the given number is valid number or not. The number is considered as valid number if it is defined by the following process:

Replace the given positive integer by the sum of the squares of its digits.

Repeat the same process {with the sum} until the number equals 1 or if loops endlessly into a cycle which does not include 1.

Those number for which this process ends in 1 are considered as valid numbers.

Sample:Input number: 19

Output: The number is valid

Process Explanation: -

1^2 + 9^2 = 82

8^2 + 2^2 = 68

6^2 + 8^2 = 100

1^2 + 0^2 + 0^2 = 1

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!