Divisor Counts ⧉
Pretty straight-forward problem. I struggled to allocate the memory at first (embarrassing), only to be reminded that I need to either globally allocate my non-const array or tag it with static
. Silly mistakes.
The solution is basically the Sieve of Eratosthenes except instead of a tagging numbers as composisite you increment a count of their divisors.
If you found this solution helpful, consider leaving a star!