Closed AKJ7 closed 4 years ago
While well-intentioned, your code is incorrect in these places:
size_t
to hold the answer, and the C standard only mandates that size_t
is unsigned and at least 16 bits wide. The answer for Problem 1 is 233168. If size_t
is indeed the same as uint16_t
(max is 65535), then the answer overflows the variable. You were probably hoping that size_t
would be the widest integer type available on the platform (like 64 bits), but this is by no means guaranteed.printf()
with a size_t
value requires the specifier %zu
, not %lu
as in your code.
I just wanted to contribute by providing my C solutions.