Check a Number is Magic Number or Not in Python

 Check a Number is Magic Number or Not in Python


Python Code

num=1535
s=0

while num!=0:
    s=s+num%10
    num=int(num/10)
print(s)
num=s
s=0
while num!=0:
    s=s+num%10
    num=int(num/10)
print(s)

if s==1:
    print("Magic Number")
else:
    print("Not a Magic Number")



Comments

Popular posts from this blog

Calculate Compound Interest in JavaScript

How to make simple bill maker by using python tkinter

Admin Login Page Using HTML and CSS