Determine if a given integer is an Armstrong number (also known as a narcissistic number). An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.
Examples:
Input: num = 153
Output: true
Explanation: 153 has 3 digits. 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
Input: num = 9474
Output: true
Explanation: 9474 has 4 digits. 9^4 + 4^4 + 7^4 + 4^4 = 6561 + 256 + 2401 + 256 = 9474
Input: num = 123
Output: false
Explanation: 123 has 3 digits. 1^3 + 2^3 + 3^3 = 1 + 8 + 27 = 36, not equal to 123
Input: num = 0
Output: true
Explanation: 0 is considered an Armstrong number (0^1 = 0)
Input: num = -5
Output: false
Explanation: Negative numbers are not Armstrong numbers
Apex Code Editor
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay Feb 2026
Contest runs February 1 - 28. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.