Skip to content

Commit 50c8c1d

Browse files
Fix: clean NeonNumber code and fix formatting
1 parent 07b4672 commit 50c8c1d

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
package 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+
*/
310
public 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
}

0 commit comments

Comments
 (0)