subject

A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. For example, 13 is a happy number since 1^2 + 3^2 = 1 + 9 = 10, 1^2 + 0^2= 1 + 0 = 1. And 85 is an unhappy number since 8^2 + 5^2 = 64 + 25 = 89, 8^2 + 9^2 = 64 + 81 = 145, 1^2 + 4^2 + 5^2= 1 + 16 + 25 = 42, 4^2 + 2^2 = 16 + 4 = 20, 2^2 + 0^2 = 4, 4^2= 16, 1^2 + 6^2 = 1 + 36 = 37, 3^2 + 7^2 = 9 + 49 = 58, 5^2 + 8^2 = 25 + 64 = 89, which is a repeated result. Write your own Java program to check whether a positive integer represented by a string is an happy number. For example, a typical string input looks like "2345678901234567899999". Note the number represented by this string could be larger than any long integers. Therefore, you should not use any method like parselnt(). You need to write your own code to hand this string. Using the code that can check whether a number represented by a string is an happy number to find all the happy numbers between 1 and 10,000, print out all the happy numbers between 9,001 and 10,000, Also in your report, you need to draw UML diagrams for your classes. find a very large happy number and a very large unhappy number. These numbers need to have at least 20 digits. Moreover, print out the sequences like the ones in examples above for 13 and 85, to show that the sequence eventually goes to 1 or the sequence is repeating.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:30
Apower user needs you to install a second type of operating system on his computer to increase efficiency while running some specialized software programs. which installation technique should you use?
Answers: 3
question
Computers and Technology, 23.06.2019 05:20
Which operating system is a version of linux?
Answers: 1
question
Computers and Technology, 23.06.2019 18:40
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
Which explains extrinsic motivation? a)motivation in which there is a reward b)motivation that is personally satisfying c)motivation that is personally meaningful d)motivation in which the subject is interesting
Answers: 1
You know the right answer?
A happy number is a number defined by the following process: Starting with any positive integer, rep...
Questions
question
Mathematics, 13.06.2021 06:00
question
Engineering, 13.06.2021 06:00
question
Mathematics, 13.06.2021 06:00
question
Engineering, 13.06.2021 06:00
question
Social Studies, 13.06.2021 06:00
Questions on the website: 13722367