Commit 1364e2b
committed
feat: Count total number of digits in an integer
🧠 Logic:
- Given an integer `n = 467777777`, we divide it repeatedly by 10 to remove its last digit.
- Each division operation indicates one digit processed, so we increment a `res` counter.
- The loop continues until `n` becomes 0.
- Finally, `res` holds the total number of digits in the original number (here, 9).
Signed-off-by: Somesh diwan <[email protected]>1 parent 4322c96 commit 1364e2b
1 file changed
+4
-3
lines changedLines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
| 6 | + | |
5 | 7 | | |
6 | | - | |
7 | | - | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
0 commit comments