What is Armstrong Number? Definition, Formula, Examples, and Programs Explained

what is armstrong number
What is Armstrong Number?

What is Armstrong Number?

If you’ve ever searched “what is Armstrong number” or “armstrong no“, you are in the right place.  Randomly selected and named Armstrong numbers (narcissistic number, or Pluperfect digital invariant – PPDI) are a form of special numbers in mathematics.

what is armstrong number
What is Armstrong Number

👉 Definition:

Armstrong numbers are number which is equal to the sum of its own digits, each raised to the power of the number of digits..if that seems confusing for a mathematical definition, check out the examples below.

For example:

  • 153 → 13+53+33=1531^3 + 5^3 + 3^3 = 15313+53+33=153 ✅ (Armstrong number)
  • 9474 → 94+44+74+44=94749^4 + 4^4 + 7^4 + 4^4 = 947494+44+74+44=9474 ✅ (Armstrong number)
  • 123 → 13+23+33=361^3 + 2^3 + 3^3 = 3613+23+33=36 ❌ (Not an Armstrong number)

Why is it Called Armstrong Number?

The name “an Armstrong number” is a phrase created by Michael F. Armstrong in a paper he published in 1962 on recreational mathematics. Armstrong numbers also are known by their other names:

  • narcissistic numbers (they love themselves by being equal their own digit power)
  • PPDI  (Pluperfect digital invariant)

Armstrong Number Formula

For an n-digit number with digits d1,d2,d3,…,dnd_1, d_2, d_3, …, d_nd1​,d2​,d3​,…,dn​:

Armstrong No =d1n+d2n+d3n+⋯+dnn\text{Armstrong Number} = d_1^n + d_2^n + d_3^n + \dots + d_n^nArmstrong Number=d1n​+d2n​+d3n​+⋯+dnn​

If the above equation holds true, the number is an Armstrong number.

Examples of Armstrong Numbers

Here are some well-known Armstrong numbers:

  • 1-digit Armstrong numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • 3-digit Armstrong numbers: 153, 370, 371, 407
  • 4-digit Armstrong numbers: 1634, 8208, 9474
  • 5-digit Armstrong numbers: 54748, 92727, 93084
  • 6-digit Armstrong numbers: 548834

Notice how rare these numbers become as the number of digits increases.

How to Check Armstrong Number Step by Step

Let’s take 153 as an example:

  1. Count the digits → 3 digits.
  2. Separate digits → 1, 5, 3.
  3. Raise each digit to the power of 3 → 13=11^3 = 113=1, 53=1255^3 = 12553=125, 33=273^3 = 2733=27.
  4. Add them up → 1+125+27=1531 + 125 + 27 = 1531+125+27=153.
  5. Compare with original → ✅ 153 = 153, so it’s an Armstrong number.

Armstrong Number Program in Python

Many people search for “Armstrong no in Python”. Here’s a simple program:

# Armstrong Number in Python

num = int(input("Enter a number: "))

power = len(str(num))

total = sum(int(digit) ** power for digit in str(num))

if num == total:

    print(num, "is an Armstrong number")

else:

    print(num, "is not an Armstrong number")

✅ Input: 153 → Output: 153 is an Armstrong number
❌ Input: 123 → Output: 123 is not an Armstrong number

Armstrong Number Program in Java

import java.util.Scanner;

public class Armstrong {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.print("Enter a number: ");

        int num = sc.nextInt();

        int temp = num, sum = 0;

        int digits = String.valueOf(num).length();

        while (temp > 0) {

            int digit = temp % 10;

            sum += Math.pow(digit, digits);

            temp /= 10;

        }

        if (sum == num)

            System.out.println(num + " is an Armstrong number");

        else

            System.out.println(num + " is not an Armstrong number");

    }

}

Armstrong Number Program in C++

#include <iostream>

#include <cmath>

using namespace std;

int main() {

    int num, sum = 0, temp, digits = 0;

    cout << "Enter a number: ";

    cin >> num;

    temp = num;

    while (temp != 0) {

        temp /= 10;

        digits++;

    }

    temp = num;

    while (temp != 0) {

        int digit = temp % 10;

        sum += pow(digit, digits);

        temp /= 10;

    }

    if (sum == num)

        cout << num << " is an Armstrong number" << endl;

    else

        cout << num << " is not an Armstrong number" << endl;

    return 0;

}

Real-Life Applications of Armstrong Numbers

Although Armstrong numbers are generally just a mathematical oddity, they are used in some:

Real-Life Applications of Armstrong Number
  • Programming interviews → a frequently encountered coding test question.
  • Cryptography puzzles → Odd numbers like these are part of number theory.
  • Math problems in an education context → These are used to show loops, conditional statements, and manipulations of digits.

FAQs About Armstrong Numbers

Q1: What does it mean to be an Armstrong number in simple terms?

A number is called an Armstrong number if the number equals the sum of its own digits raised to the power of the number of digits.

Q2: Is 153 an Armstrong number?

Yes, because 1^3 + 5^3 + 3^3 = 1531^3 + 5^3 + 3^3 = 153 1^3 + 5^3 + 3^3 = 153.

Q3: Is 9474 Armstrong number?

Yes, because 9^4 + 4^4 + 7^4 + 4^4 = 94749^4 + 4^4 + 7^4 + 4^4 = 94749^4 + 4^4 + 7^4 + 4^4 = 9474.

Q4: Are Armstrong numbers the same as narcissistic numbers?

Yes, Armstrong numbers are also known as narcissistic numbers.

Q5: How to check Armstrong number in Python or Java?

Using digit extraction and raising each digit to the power of the total number of digits and comparing the sum to the original number.

Final Thoughts on Armstrong Numbers

So, now you know what is Armstrong number (or armstrong no…) These numbers are mathematical gems that often show up in programming challenges, math puzzles, and coding interviews.

They may not have any deep real world applications in science or finance, but they are a simple and fun way of demonstrating the properties of numbers, as well as logic and problem solving in a coding context.

Next time someone asks “what is Armstrong number?” you will have not only the definition, but some examples, formulas, and programs written in multiple programming languages to share. 🚀

0 Shares:
You May Also Like