Mode Gelap

Recent in Fashion

Best Seller Books

Range Armstrong

  • Problem Description

    Write a program to find the armstrong numbers between the given range
    Input 1:Lower Range

    Input 2: Upper range

    Output:
    List of Armstrong numbers

    Refer sample input and output for formatting specification.
  • CODING ARENA
  • lower=int(input())
    upper=int(input())
    for num in range(lower, upper + 1):
       order = len(str(num))
        

       sum = 0

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

       if num == sum:
           print(num)
  • Test Case 1

    Input (stdin)
    100

    2000

    Expected Output
    153

    370

    371

    407

    1634
  • Test Case 2

    Input (stdin)
    100

    1000

    Expected Output
    153

    370

    371

    407

Subscribe Our Newsletter

avatar
"By speaking behind my back, it means that you respect my existence enough not to act in front of my face."

Related Posts

0 Comment

Post a Comment

Article Top Ads

Parallax Ads

Article Center Ads

Article Bottom Ads