Commit d39b04e
committed
feat: Check if a number is an Armstrong number with digit-wise cube breakdown
🧠 Logic:
- Read integer input from the user.
- Store the original number to compare later.
- Loop through each digit of the number:
- Extract last digit using `% 10`.
- Calculate its cube and add to running sum.
- Print the digit and its cube for traceability.
- After loop, compare sum of cubes with original number:
- If equal, it is an Armstrong number.
Signed-off-by: Somesh diwan <[email protected]>1 parent f736005 commit d39b04e
1 file changed
+35
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments