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

Function sumDigitsSquared

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

Source from the content-addressed store, hash-verified

12}
13
14function sumDigitsSquared(num) {
15 let total = 0n;
16 while (num > 0) {
17 const numModBase = num % 10n;
18 total += numModBase ** 2n;
19 num = num / 10n;
20 }
21 return total;
22}
23
24function isHappy(num) {
25 while (num != 1n && num != 4n) {

Callers 1

isHappyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected