subject

Start with any positive integer, replace the number by the sum of the squares of its digits in base-ten, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle that include number 4. Those numbers for which this process ends in 1 are called happy numbers, others are unhappy or sad numbers.
Examples:
208 -> 2*2 + 8*8 = 68 -> 6*6 + 8*8 = 100 -> 1*1 = 1 ---> HAPPY NUMBER :)
145 -> 1*1 + 4*4 + 5*5 = 42 -> 4*4 + 2*2 = 20 -> 2*2 = 4 ---> SAD NUMBER :(

Write a program that gets a number and says if it is happy or not.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 10:00, austintules2005
Whats three fourths of 15(this is supposed to be in math but i clicked too fast)
Answers: 1
image
Computers and Technology, 23.06.2019 14:00, LuvIsRage2
Technician a says that with self-adjusting clutch systems, the release bearing constantly rotates. technician b says that the ball bearing portion of the release bearing should be lubricated with high-temperature grease during routine maintenance. which technician is correct?
Answers: 2
image
Computers and Technology, 24.06.2019 00:50, sequoyaburke
Which player type acts on other players? a. killer b. achiever c. explorer d. socializer
Answers: 1
image
Computers and Technology, 24.06.2019 10:00, noahmace
When writing a business letter, how many times can you use the same merge field in a document? once once, unless using the address block feature unlimited it will depend on the type of document you choose
Answers: 1
You know the right answer?
Start with any positive integer, replace the number by the sum of the squares of its digits in base-...

Questions in other subjects:

Konu
Mathematics, 19.06.2020 19:57