Sieve of Eratosthenes algorithm implementation