Question: Python 3.6.1 A happy number is found using the following process. Pick a number. Separate out its digits. Square them. Add them together to form

Python 3.6.1

A happy number is found using the following process. Pick a number. Separate out its digits. Square them. Add them together to form a new number. Repeat. If the eventual product is one, youve got a happy number. For example, consider the number 7. Is it happy?

S0: 7

S1: 7 2 = 49

S2: 4 2 + 92 = 97

S3: 9 2 + 72 = 130

S4: 1 2 + 32 + 02 = 10

S5: 1 2 + 02 = 1

The number 7 becomes happy in 5 steps. Write a program with Python that asks for an integer number. If the number is happy, the program prints is Happy. Otherwise, it prints is Non-happy. Numbers that are happy follow a sequence that ends in 1. All non-happy numbers follow sequences that reach the cycle: 4, 16, 37, 58, 89, 145, 42, 20, 4, ...

Desired Output Example

Python 3.6.1 A happy number is found using the following process. Pick

For example 1Enter an integer number 7 2 Number 7 is Happy Enter an integer number: 950 2 Number 950 is Non -happy

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!