MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / isHappy

Method isHappy

Java/Happy-Number.java:2–17  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

1class HappyNumber {
2 public boolean isHappy(int n) {
3 int num1, num2;
4
5 num1 = num2 = n;
6 do
7 {
8 num1 = SquareSum(num1);
9
10
11 num2 = SquareSum(SquareSum(num2));
12
13 }
14 while (num1 != num2);
15
16 return (num1 == 1);
17}
18
19
20static int SquareSum(int n)

Callers

nothing calls this directly

Calls 1

SquareSumMethod · 0.95

Tested by

no test coverage detected