Python 3 Script to Find Whether a Number is Strong or Not Using While and For Loop Full Project For Beginners

Python 3 Script to Find Whether a Number is Strong or Not Using While and For Loop Full Project For Beginners

 

Welcome folks today in this blog post we will be checking whether a number is strong or not using for loop and while loop in python.All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

Using While Loop

 

app.py

 

# Python Program to find Strong Number
 
Number = int(input(" Please Enter any Number: "))
Sum = 0
Temp = Number

while(Temp > 0):
    Factorial = 1
    i = 1
    Reminder = Temp % 10

    while(i <= Reminder):
        Factorial = Factorial * i
        i = i + 1

    print("\n Factorial of %d = %d" %(Reminder, Factorial))
    Sum = Sum + Factorial
    Temp = Temp // 10

print("\n Sum of Factorials of a Given Number %d = %d" %(Number, Sum))
    
if (Sum == Number):
    print(" %d is a Strong Number" %Number)
else:
    print(" %d is not a Strong Number" %Number)

 

See also  Python 3 Telegram API Bot to Send Messages to Telegram Users Using Telebot and Telethon Library Full Project For Beginners

 

Using For Loop

 

 

app.py

 

# Python Program to find Strong Number
 
Number = int(input(" Please Enter any Number: "))
Sum = 0
Temp = Number

while(Temp > 0):
    Factorial = 1
    Reminder = Temp % 10

    for i in range(1, Reminder + 1):
        Factorial = Factorial * i

    print("Factorial of %d = %d" %(Reminder, Factorial))
    Sum = Sum + Factorial
    Temp = Temp // 10

print("\n Sum of Factorials of a Given Number %d = %d" %(Number, Sum))
    
if (Sum == Number):
    print(" %d is a Strong Number" %Number)
else:
    print(" %d is not a Strong Number" %Number)

 

See also  Python 3 Kivy Music MP3 Player to Play Songs and Music GUI Desktop App Full Project For Beginners

 

If you execute the python script by typing the below command as shown below

 

python app.py

 

Leave a Reply