Armstrong Number in PYTHON
An Armstrong Number is a special kind of number in which the sum of their digits provided raise to the power of the number of digit is equal
for example:-
153 is an Armstrong Number
1^3+5^3+3^3=153
#You can check out#
1634 is also an Armstrong Number
1^4+6^4+3^4+4^4=1634
Let's check the coding behind it..
no=int(input ("enter the no:"))
dig=len(str(no))
temp=no
sum=0
while temp>0:
d=temp%10
sum=sum+d**dig
temp=temp//10
if sum==no:
print("Yes it's an Armstrong Number")
else:
print("Sorry! it's not try another one ")
OUTPUT:
enter the no:153
Yes it's an Armstrong Number
enter the no:1634
Yes it's an Armstrong Number
enter the no:1234
Sorry!it's not try another one
Need some introduction to python for beginners.
ReplyDeleteFor me😀
Soon we will share post related to this topic
DeleteTry posting "raspberry pi" codes.
ReplyDeleteThey are trending🔥 now.
Thanks for your valuable feedback
Delete👌👌
ReplyDelete