Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python Program to Find Armstrong Number in an Interval

# Program to check Armstrong numbers in a certain interval

lower = 100
upper = 2000

for num in range(lower, upper + 1):

   # order of number
   order = len(str(num))
    
   # initialize sum
   sum = 0

   temp = num
   while temp > 0:
       digit = temp % 10
       sum += digit ** order
       temp //= 10

   if num == sum:
       print(num)
Comment

PREVIOUS NEXT
Code Example
Python :: python set remove multiple elements 
Python :: flask subdomains 
Python :: check remote port is open or not using python 
Python :: pandas read csv skip rows 
Python :: outlier removal 
Python :: leap year python 
Python :: staticfiles 
Python :: how to load mnist dataset in python 
Python :: datafram combine 3 columns to datetime 
Python :: how to split text into list python by characters 
Python :: select rows from dataframe pandas 
Python :: pygame mirror image 
Python :: install fasttext python 
Python :: wait driver selenium 
Python :: how to make a variable 
Python :: what is NoReverseMatch in django? 
Python :: how to use h5 file in python 
Python :: rename pandas columns with list of new names 
Python :: number of column in dataset pandas 
Python :: print out a name in python 
Python :: simple graph in matplotlib categorical variables 
Python :: find percentage of missing values in a column in python 
Python :: How to take total count of words in the list python 
Python :: python get all combinations of list 
Python :: trim starting space python 
Python :: how to add phone number to django user model 
Python :: how to make a button in python turtle 
Python :: see attributes of object python 
Python :: tuple plot python 
Python :: python sort array by value 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =