Questions tagged [sieve-of-eratosthenes]

Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to a specified integer.

Sieve of Eratosthenes finds primes among the natural numbers above 1 between the composites, which it finds by direct enumeration from each prime (optimization: prime's square), as an arithmetic progression with the step equal to that prime.

The first prime number is 2.

In pseudocode, the timing issues aside, it is

primes = [2, 3, ...] \ [[p*p, p*p+p, ...] for p in primes]

469 questions
-4
votes
3 answers

run time error (SIGSEGV) SPOJ Sieve of Eratosthenes

Hi I'm getting SIGSEGV error for this problem, dont know where is th problem: http://www.spoj.com/problems/PRIME1/ I tried to solve it by sieve-of-Eratosthenes algo given on Wikipedia. here is my code, please help thanks in advance. int main() { …
vickydon
  • 11
  • 2
-4
votes
1 answer

Segmentation Fault with Sieves of Eratosthenes algorithm in C

Okay, so this function I created uses the Sieve of Eratosthenes algorithm to compute all the primes <= n. This function stores the prime numbers and the count of primes in the parameters. When the function exits, primes should be pointing to a chunk…
Hetero Myde
  • 25
  • 1
  • 5
-6
votes
1 answer

can Wolfram factor 300 digit RSA Number?

Everybody knows its hard to factor over 100 digit public key but 250 digits RSA number have already been factored and Wolfram was able to factor a 300 digit number. I tried factorizing public key…
user14621633
-7
votes
1 answer

Segmented sieve of eratosthenes spoj Prime1 C++

I have been struggling with this problem http://www.spoj.com/problems/PRIME1/ and if anyone can help me finding the error in my code. I have used segmented sieve of eratosthenes and I have also looked through a lot of online resources but somehow I…
1 2 3
31
32