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

Function sumDigitsSquared

ch3-happycoin/happycoin.js:9–17  ·  view source on GitHub ↗
(num)

Source from the content-addressed store, hash-verified

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

Callers 1

isHappyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected