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, 22.06.2019 11:30
To hide gridline when you display or print a worksheet
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
When early motion pictures played in movie theaters, they were often accompanied by live organ or piano music. which of the following are the most likely reasons that this happened? (select all that apply). the music was provided to distract audience members from the loud sounds made when filmstrips were changed. the music accompanied the movies because the movies were silent and audiences were used to hearing music during plays in theaters. the music usually was played before, and sometimes after the movie, as an alternative form of entertainment. the music viewers to interpret the dramatic action in the films.
Answers: 2
question
Computers and Technology, 23.06.2019 10:00
Whats three fourths of 15(this is supposed to be in math but i clicked too fast)
Answers: 1
question
Computers and Technology, 24.06.2019 03:00
Click the "draw structure" button to activate the drawing utility. draw two diastereomers of (1z,4r)−1,4−dimethylcyclodecene and name them, including (e)/(z) and (r)/(s) notation. part 1 out of 4 draw the diastereomer containing a chiral center with s configuration here. window open
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
Chemistry, 16.10.2020 15:01
question
Spanish, 16.10.2020 15:01
question
Business, 16.10.2020 15:01
question
Mathematics, 16.10.2020 15:01
question
Mathematics, 16.10.2020 15:01
question
English, 16.10.2020 15:01
question
English, 16.10.2020 15:01
question
Physics, 16.10.2020 15:01
Questions on the website: 13722361