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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:00, lilyforeman5867
Match each vocabulary word to its definition.1. desktoppicture used to represent acomputer application2. domainnetwork protectionsoftware code that can be viewed,3. iconmodified, and redistributed for freethe background screen on acomputer monitor4. url5. blogan online journalthe part of an internet address that6. firewallrefers to a group of computers on anetworkonline database of web pages7. intranetnetwork for use by an individual8. open address of a web page or9. wikiresource
Answers: 2
image
Computers and Technology, 22.06.2019 18:30, ovoxotas
Which of the following commands is more recommended while creating a bot?
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, LouieHBK
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe and
Answers: 1
image
Computers and Technology, 24.06.2019 06:00, bzhsh8282
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
A happy number is a number defined by the following process: Starting with any positive integer, rep...

Questions in other subjects:

Konu
Social Studies, 08.07.2019 05:30
Konu
Mathematics, 08.07.2019 05:30
Konu
Physics, 08.07.2019 05:30