
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Armstrong Number Check
								Certification: Basic Level
								Accuracy: 50%
								Submissions: 8
								Points: 10
							
							Write a C++ program to determine if a given non-negative integer is an Armstrong number. An Armstrong number is a number that is equal to the sum of its digits each raised to the power of the number of digits.
Example 1
- Input: number = 153
- Output: 1
- Explanation: - Step 1: Count the number of digits in 153. There are 3 digits.
- Step 2: Calculate the sum of each digit raised to the power of the number of digits: 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153.
- Step 3: Since the sum equals the original number, 153 is an Armstrong number, so return 1.
 
Example 2
- Input: number = 123
- Output: 0
- Explanation: - Step 1: Count the number of digits in 123. There are 3 digits.
- Step 2: Calculate the sum of each digit raised to the power of the number of digits: 1^3 + 2^3 + 3^3 = 1 + 8 + 27 = 36.
- Step 3: Since the sum does not equal the original number, 123 is not an Armstrong number, so return 0.
 
Constraints
- 0 ≤ number ≤ 10^9
- Output 1 if the number is an Armstrong number, 0 otherwise
- Time Complexity: O(d), where d is the number of digits
- Space Complexity: O(1)
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Calculate the number of digits in the given number.
- For each digit, compute its value raised to the power of the number of digits and sum them.
- Compare the computed sum to the original number to determine if it's an Armstrong number.
