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 11package com .thealgorithms .maths ;
22
3+ /**
4+ * Neon Number algorithm.
5+ * A number whose sum of digits of its square equals the number itself.
6+ * Example: 9^2=81⇒8+1=9
7+ *
8+ * @see <a href="https://en.wikipedia.org/wiki/Recreational_mathematics">Wikipedia</a>
9+ */
310public class NeonNumber {
411
5- private NeonNumber (){
12+ private NeonNumber () {
613 }
7- /**
8- * Check if a number is Neon Number.
9- * A neon number is a number where a sum of digits of its square equals the number itself.
10- * Example : 9--> 9^2 = 81 --> 8+1 = 9
11- * @see <a href="https://en.wikipedia.org/wiki/Recreational_mathematics">
12- * * Wikipedia - Recreational Mathematics</a>
13- * @param number the number to check
14- * @return true if neon number, else --> false
15- */
1614
17-
18- public static boolean isNeon (int number )
19- {
20- int square = number *number ;
15+ public static boolean isNeon (int number ) {
16+ int square = number * number ;
2117 int digitSum = 0 ;
22- while (square > 0 ) {
18+ while (square > 0 ) {
2319 digitSum += square % 10 ;
24- square /= 10 ;
20+ square /= 10 ;
2521 }
2622 return digitSum == number ;
2723 }
28-
29-
3024}
You can’t perform that action at this time.
0 commit comments