Python Program to Check Armstrong Number

preview_player
Показать описание
Hi,

In this video I tried to explain Python Program to Check Armstrong Number.

Python Scripts
======================

Python Functions Solved
==========================

Python Programs Solved
============================

153 a 3 digit number is said to be Armstrong number if sum of individual numbers raised to cube is equals to original number itself.

Another four digit Armstrong Number is 1634.

Below is the program works for any length
========================================
number = int(input("Enter a number : "))
length = len(str(number))
temp = number
sum_of_powers = 0
while( temp != 0 ):
x = temp % 10
sum_of_powers = sum_of_powers + x ** length
temp = temp // 10
if sum_of_powers == number:
print("Number is Armstrong")
else:
print("Number is not an Armstrong")

Hope you liked this video. Please subscribe to this channel for more #Python Related videos.
Рекомендации по теме