Number = int(input("Enter the Number to Check Armstrong: ")) Sum = 0 Times = 0 Temp = Number while Temp > 0: Times = Times + 1 Temp = Temp // 10 Temp = Number while Temp > 0: rem = Temp % 10 Sum = Sum + (rem ** Times) Temp //= 10 if Number == Sum: print("\n %d is Armstrong Number.\n" %Number) else: print("\n %d is Not a Armstrong Number.\n" %Number)
ScreenShot:
No comments:
Post a Comment