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

Function sum_digits_squared

ch1-c-threads/happycoin-threads.c:22–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22uint64_t sum_digits_squared(uint64_t num) {
23 uint64_t total = 0;
24 while (num > 0) {
25 uint64_t num_mod_base = num % 10;
26 total += num_mod_base * num_mod_base;
27 num = num / 10;
28 }
29 return total;
30}
31
32bool is_happy(uint64_t num) {
33 while (num != 1 && num != 4) {

Callers 1

is_happyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected