Menu Close

Find the Armstrong numbers between the given range

Write a program to find the Armstrong numbers between the given range.
Input 1:Lower Range
Input 2: Upper rangesxss

LR=int(input("Enter the lower range: "))
UR=int(input("Enter the upper range: "))

for i in range(LR,UR+1):

	sum1 = 0
	temp = i
	temp2=str(i)
	digitlength=len(temp2)
	while temp > 0:
		digit = temp % 10
		sum1+= digit ** digitlength      # particular number to the power of 3, (number**n)
		temp //= 10                      #Floor Division, returns only the result(quotient without the floating point)

	if i == sum1:
		print(i)

Sample
Input_1:
       Enter the lower range: 1000
       Enter the upper range: 1000000
Output:
      1634
      8208
      9474
      54748
      92727
      93084
      548834


Input_2:
          Enter the lower range: 100
          Enter the upper range: 2000
Output:
          153
          370
          371
          407
         1634


Morae!Q!

->Insert and Extend in list python
->Print Odd Numbers in range
->Compare List in python
->Find whether the largest element in the array is at least twice as much as every other number in the array.
->Find minimum cost to reach the top of the floor
->Word Count in Python
->Lower case to upper case in python
->Display Time in python
->Sum of Odd And Even in Python
->Surface Area of Walls
->Find the sum of squares of individual digits
->Print the given series – 1 1 2 6 24
->Minimum number of steps required to reach destination.
->Seconds to Days Hours Minutes
->Program to remove add “Hyphen” character in the entered string
->Remove the nth Index Character from a Non-Empty String
->Relational operator Question
->Check whether all the given numbers lies in range of x and y.
->Find the Armstrong numbers between the given range.