4. Sieve of Eratosthenes
Моля за малко помощ на задачата 4. Sieve of Eratosthenes от Arrays and Lists - Exercises, защото джъджа ми дава 40.
Write a program to find all prime numbers in range [1…n]. Implement the algorithm called “Sieve of Eratosthenes”: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes. Steps in the “Sieve of Eratosthenes” algorithm:
- Assign primes[0…n] = true
- Assign primes[0] = primes[1] = false
- Find the smallest p, which holds primes[p] = true
- Print p (it is prime)
- Assign primes[2*p] = primes[3*p] = primes[4*p] = … = false
- Repeat for the next smallest p < n.
http://pastebin.com/QuqyAWP5 това е моя код, ако някой ми помогне ще му бъда благодарен!