MCPcopy Create free account
hub / github.com/MultithreadedJSBook/code-samples / isHappy

Function isHappy

ch3-happycoin/happycoin-threads.js:24–29  ·  view source on GitHub ↗
(num)

Source from the content-addressed store, hash-verified

22}
23
24function isHappy(num) {
25 while (num != 1n && num != 4n) {
26 num = sumDigitsSquared(num);
27 }
28 return num === 1n;
29}
30
31function isHappycoin(num) {
32 return isHappy(num) && num % 10000n === 0n;

Callers 1

isHappycoinFunction · 0.70

Calls 1

sumDigitsSquaredFunction · 0.70

Tested by

no test coverage detected