Program - function to print all armstrong in a range


Topic: Program - function to print all armstrong in a range

Solution

def print_all_armstrong(lower: int, upper: int):
    for num in range(lower,upper + 1):  
        sum_ = 0
        temp = num
        while temp > 0:
            digit = temp % 10
            sum_ += digit ** 3
            temp //= 10
            if num == sum_:
                print(num)



List all Python Programs