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

Function isHappy

ch7-happycoin-as/happycoin.ts:20–25  ·  view source on GitHub ↗
(num: u64)

Source from the content-addressed store, hash-verified

18}
19
20function isHappy(num: u64): boolean {
21 while (num != 1 && num != 4) {
22 num = sumDigitsSquared(num);
23 }
24 return num === 1;
25}
26
27function isHappycoin(num: u64): boolean {
28 return isHappy(num) && num % 10000 === 0;

Callers 1

isHappycoinFunction · 0.70

Calls 1

sumDigitsSquaredFunction · 0.70

Tested by

no test coverage detected