Answer to Question #246376 in Python for Isabel Cortez

Question #246376

3. Disarium Number


A number is said to be Disarium if the sum of its digits raised to their respective positions is the number itself.


Example:

75

7^1+5^2=7+25=32 → False


135

1^1+3^2+5^3=1^9+125=135 → True


Print True if a number is a Disarium, otherwise print False.



Input

The Input will be any integer


135



Output


True


1
Expert's answer
2021-10-04T04:57:33-0400

Source code


N=int(input("Enter an integer: "))
str_n=str(N)
sum_n=0
for i in range(1,(len(str_n)+1)):
    n=int(str_n[i-1])
    sum_n+=n**i


if sum_n==N:
    print("True")
else:
    print("False")


Sample output 1




Sample output 2





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS