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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started