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.
कंप्यूटर कितने प्रकार के होते हैं? (Types of Computers in Hindi)
जानिए कंप्यूटर कितने प्रकार के होते हैं (Types of computers)। Micro, Mini, Mainframe, और Supercomputer के बीच का अंतर हिंदी में समझें।
Top 20 Computer Related Full Forms for Exams
A complete list of the most important computer-related full forms. Learn the full forms of CPU, RAM, ROM, HTTP, USB, and GUI for basic computer exams.
Computer Science Class 12 Syllabus Overview
Explore the CBSE Computer Science Class 12 syllabus. Learn about Python programming, SQL databases, and computer networks essential for board exams.
Control Statements in Java: Types and Examples
Learn about the three types of control statements in Java: Decision making (if-else), Iteration loops (for, while), and Jump statements (break, continue).
What is Control+Z Used For?
Learn what the Ctrl+Z keyboard shortcut is used for. Discover how the 'Undo' function works in word processing, photo editing, and file management.
Turn this guide into revision flashcards, a practice exam, or an AI-generated podcast — free, no signup required.