Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago

Question

Solve the integral:

Answered: 1 week ago

Question

What is meant by Non-programmed decision?

Answered: 1 week ago