Computer Science, asked by gznwzaf656, 4 months ago

write a program to accept any number and check whether it is a disarium number or not



pls answer​

Answers

Answered by allysia
2

Answer:

In python:

_______________________

n=int(input("Enter a number: "))

b=str(n)

s=0

for i in range(0,len(b)):

   s=s+int(b[i])**(i+1)

if n==int(s):

   print("Yes, it is a Disarium")

else:

   print("No, it's not a Disarium")

________________________

Picture in the attachment.

Explanation:

Disarium is a number whose each digit when raised to the power of their position number return the same number, as in 175,

1^{1} +7^{2} +5^{3} = 1+49+125= 175.

Attachments:
Similar questions