Question: Java: Write a method named isHappyNumber that returns whether a given integer is happy. An integer is happy if repeatedly summing the squares of its

Java:

Write a method named isHappyNumber that returns whether a given integer is "happy". An integer is "happy" if repeatedly summing the squares of its digits eventually leads to the number 1.

For example, 139 is happy because:

12 + 32 + 92 = 91

92 + 12 = 82

82 + 22 = 68

62 + 82 = 100

12 + 02 + 02 = 1

By contrast, 4 is not happy because:

42 = 16

12 + 62 = 37

32 + 72 = 58

52 + 82 = 89

82 + 92 = 145

12 + 42 + 52 = 42

42 + 22 = 20

22 + 02 = 4

...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!