Skip to content

Commit f8c6288

Browse files
Fix formatting: remove trailing spaces and apply clang-format
1 parent 194c699 commit f8c6288

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/main/java/com/thealgorithms/maths/HappyNumber.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* A Happy Number is defined as a number which eventually reaches 1 when replaced
55
* by the sum of the squares of each digit.
66
* If it falls into a cycle that does not include 1, then it is not a happy number.
7-
*
7+
88
* Example:
9-
* 19 → 1² + 9² = 82
10-
* 82 → 8² + 2² = 68
11-
* 68 → 6² + 8² = 100
12-
* 100 → 1² + 0² + 0² = 1 → Happy Number!
9+
* 19 → 1² + 9² = 82
10+
* 82 → 8² + 2² = 68
11+
* 68 → 6² + 8² = 100
12+
* 100 → 1² + 0² + 0² = 1 → Happy Number!
1313
*/
1414
public final class HappyNumber {
1515

@@ -29,8 +29,8 @@ public static boolean isHappy(int n) {
2929
int fast = n;
3030

3131
do {
32-
slow = sumOfSquares(slow); // move 1 step
33-
fast = sumOfSquares(sumOfSquares(fast)); // move 2 steps
32+
slow = sumOfSquares(slow); // move 1 step
33+
fast = sumOfSquares(sumOfSquares(fast)); // move 2 steps
3434
} while (slow != fast);
3535

3636
return slow == 1; // If cycle ends in 1 → Happy number
@@ -40,7 +40,7 @@ public static boolean isHappy(int n) {
4040
* Calculates the sum of squares of the digits of a number.
4141
*
4242
* Example:
43-
* num = 82 → 8² + 2² = 64 + 4 = 68
43+
* num = 82 → 8² + 2² = 64 + 4 = 68
4444
*
4545
* @param num The number to calculate sum of squares of digits
4646
* @return The sum of squares of the digits

src/test/java/com/thealgorithms/maths/HappyNumberTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ void testUnhappyNumbers() {
2626
@Test
2727
void testLargeNumber() {
2828
// Just to check behavior with larger input
29-
assertTrue(HappyNumber.isHappy(1000000)); // reduces to 1 eventually
29+
assertTrue(HappyNumber.isHappy(1000000)); // reduces to 1 eventually
3030
}
3131
}

0 commit comments

Comments
 (0)