Python Compiler
import math start = 1; end = 200; flag = 0; print("Armstrong numbers between %d and %d: " % (start, end)) for start in range(start, end+1): #find number of digits in start variable copyNum = start; total = 0; digits = 0; remainder = 0; while(copyNum != 0): digits += 1 copyNum = math.floor(copyNum / 10) copyNum = start; #slice the numbers from last digits while(copyNum != 0): remainder = copyNum % 10; total += pow(remainder, digits); copyNum = math.floor(copyNum / 10); if((start == total) and (start != 0)): flag = 1 print(start, end=" ") if(flag == 0): print("There is no armstrong number between the given range")
OUTPUT
Armstrong numbers between 1 and 200: 
1 2 3 4 5 6 7 8 9 153
×

Save as Private