DEV Community

Cover image for Check for Armstrong Number
Deepak Raj
Deepak Raj

Posted on • Edited on • Originally published at codeperfectplus.com

6 4

Check for Armstrong Number

Alt Text

Topic : Armstrong Number

Problem Statement:

An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 153 is an Armstrong number since

1**3 + 5 **3 + 3**3 = 153.
Enter fullscreen mode Exit fullscreen mode

Write a program to check the number is Armstrong number is not.

def is_armstrong_number(number):
    num = str(number)
    exp = len(num)
    return number == sum([int(i)**exp for i in num])
Enter fullscreen mode Exit fullscreen mode

Share your solution to check Armstrong number.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay