An Armstrong number (also called a narcissistic number) is a number that equals the sum of its own digits each raised to the power of the number of digits.
Example: 153 = 1³ + 5³ + 3³ = 1 + 125 + 27 = 153 ✓
Definition: Sum of (each digit)^(number of digits) equals the number itself.
3-digit Examples: 153, 370, 371, 407.
Also Called: Narcissistic numbers or Pluperfect digital invariants.
Logic: Extract each digit, raise to power n, sum them up.
num = int(input('Enter a number: '))
original = num
result = 0
n = len(str(num)) # number of digits
while num > 0:
digit = num % 10
result += digit ** n
num //= 10
if result == original:
print(f'{original} is an Armstrong number')
else:
print(f'{original} is NOT an Armstrong number')
import java.util.Scanner;
public class Armstrong {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int original = num, result = 0;
int n = String.valueOf(num).length();
while (num > 0) {
int digit = num % 10;
result += Math.pow(digit, n);
num /= 10;
}
if (result == original)
System.out.println(original + " is Armstrong");
else
System.out.println(original + " is not Armstrong");
}
}
An Armstrong number equals the sum of its own digits, each raised to the power equal to the number of digits. Example: 153 = 1³ + 5³ + 3³.
Yes! 9474 is a 4-digit Armstrong number: 9⁴ + 4⁴ + 7⁴ + 4⁴ = 6561+256+2401+256 = 9474.
What Does a Computer Consist of? — Components Explained
Learn what a computer consists of. CPU, input devices, output devices, memory, and storage — all basic computer components explained for Class 6 to 10.
Advantages and Disadvantages of Computers in Daily Life
Explore the major advantages and disadvantages of computers in our daily lives. A complete list of pros and cons for school students.
Advantages of Database Management Systems (DBMS)
Learn the key advantages of using a Database Management System (DBMS) over traditional file systems, including data security, consistency, and sharing.
Important Computer Full Forms You Should Know
A complete list of all important computer full forms and abbreviations, including CPU, RAM, ROM, URL, HTTP, and USB. Perfect for competitive exams.
What are the Applications of Stack in Data Structures?
Learn the real-world and computational applications of the Stack data structure. Understand its role in undo features, parsing, and recursion.
Turn this guide into revision flashcards, a practice exam, or an AI-generated podcast — free, no signup required.