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

Function sumDigitsSquared

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

Source from the content-addressed store, hash-verified

8}
9
10function sumDigitsSquared(num: u64): u64 {
11 let total: u64 = 0;
12 while (num > 0) {
13 const numModBase = num % 10;
14 total += numModBase ** 2;
15 num = num / 10;
16 }
17 return total;
18}
19
20function isHappy(num: u64): boolean {
21 while (num != 1 && num != 4) {

Callers 1

isHappyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected