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

Function sum_digits_squared

ch1-c-threads/happycoin.c:16–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16uint64_t sum_digits_squared(uint64_t num) {
17 uint64_t total = 0;
18 while (num > 0) {
19 uint64_t num_mod_base = num % 10;
20 total += num_mod_base * num_mod_base;
21 num = num / 10;
22 }
23 return total;
24}
25
26bool is_happy(uint64_t num) {
27 while (num != 1 && num != 4) {

Callers 1

is_happyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected