Commit 9bc05e9
committed
feat: Check if a number is an Armstrong number (3-digit)
🧠 Logic:
- Take integer input `n`, store original in `m`.
- Initialize `sum = 0`.
- Extract digits using `% 10` and compute cube of each digit.
- Accumulate sum of cubes.
- After loop, compare `sum` with original number `m`.
- If equal → Armstrong number.
Signed-off-by: Somesh diwan <[email protected]>1 parent d6f147b commit 9bc05e9
1 file changed
+4
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
21 | | - | |
| 19 | + | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
| |||
0 commit comments