LC: 1134. Armstrong Number - spiralgo/algorithms GitHub Wiki
1134. Armstrong Number:
The Essence: The question tries to teach us:
- Splitting a number into individual digits.
- Finding the length of a number.
Details:
- We can split a number into individual digits in a while loop, getting the last digit with modulo sign (%) and dividing the number by 10.
- We can find the length of a number, simply covering it to a String and calling the "length()" function.
(There is also a mathematical method to find the length: int length = (int) Math.log10(n) + 1;)