Computers and Technology

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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:50, minideeri
The file sales data. xlsx contains monthly sales amounts for 40 sales regions. write a sub that uses a for loop to color the interior of every other row (rows 3, 5, etc.) gray. color only the data area, columns a to m. (check the file colors in excel. xlsm to find a nice color of gray.)
Answers: 2
image
Computers and Technology, 22.06.2019 22:30, josephmelichar777
Write a full class definition for a class named player , and containing the following members: a data member name of type string .a data member score of type int .a member function called setname that accepts a parameter and assigns it to name . the function returns no value. a member function called setscore that accepts a parameter and assigns it to score . the function returns no value. a member function called getname that accepts no parameters and returns the value of name .a member function called getscore that accepts no parameters and returns the value of score .this is what i have, aparently this is wrong: class player{private: string name; int score; public: void player: : setname (string n){name =n; }void player: : setscore (int s){score = s; }string player: : getname (){return name; }int player: : getscore (){return score; }};
Answers: 2
image
Computers and Technology, 23.06.2019 19:00, jacobbecker99
Choose the correct citation for the case which established the "minimum contacts" test for a court's jurisdiction in a case. select one: a. brown v. board of education of topeka, 347 u. s. 483 (1954). b. international shoe co. v. washington, 326 u. s. 310 (1945) c. haynes v. gore, 531 u. s. 98 (2000). d. international shoe co. v. washington, 14 u. s. code 336.
Answers: 1
image
Computers and Technology, 23.06.2019 22:30, delawdermia27
The output voltage of a power supply is assumed to be normally distributed. sixteen observations are taken at random on voltage are as follows: 10.35, 9.30, 10.00, 9.96, 11.65, 12.00, 11.25, 9.58, 11.54, 9.95, 10.28, 8.37, 10.44, 9.25, 9.38, and 10.85
Answers: 1
Do you know the correct answer?
A happy number is a number defined by the following process: Starting with any positive integer, rep...

Questions in other subjects:

Konu
Mathematics, 09.03.2021 22:00
Konu
Mathematics, 09.03.2021 22:00