File tree Expand file tree Collapse file tree
src/main/java/com/thealgorithms/maths Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 * A number whose sum of digits of its square equals the number itself.
66 * Example: 9 - 9^2 = 81 - 8+1 = 9
77 *
8- * @see <a href="https://en.wikipedia.org/wiki/Recreational_mathematics">Wikipedia</a>
8+ * @see <a href="https://en.wikipedia.org/wiki/Recreational_mathematics">
9+ * Wikipedia</a>
910 */
10- public class NeonNumber {
11+ public final class NeonNumber {
1112
1213 private NeonNumber () {
1314 }
1415
16+ /**
17+ * Check if a number is a Neon number.
18+ *
19+ * @param number the input number
20+ * @return true if neon number, false otherwise
21+ */
1522 public static boolean isNeon (final int number ) {
1623 int square = number * number ;
1724 int digitSum = 0 ;
1825 int temp = square ;
1926 while (temp > 0 ) {
20- digitSum += temp % 10 ;
27+ digitSum = digitSum + temp % 10 ;
2128 temp /= 10 ;
2229 }
2330 return digitSum == number ;
You can’t perform that action at this time.
0 commit comments