Questions tagged [sieve-of-atkin]

A modern prime number sieve with better computational complexity than that of the sieve of Eratosthenes.

A modern prime number sieve with better computational complexity than that of the sieve of Eratosthenes. See https://en.wikipedia.org/wiki/Sieve_of_Atkin.

25 questions
1
vote
3 answers

What is the space complexity of a prime sieve with data in proportion to number of primes?

I'm practicing writing algorithms optimized for space or time complexity. With prime sieves, at minimum you must store a list of all primes found. It seems data in proportion to the number of primes found is the least amount of space such an…
1
vote
2 answers

Getting SIGABRT in c++ in the following program

I submitted this problem in spoj and this is showing runtime error(SIGABRT). It's working properly on my machine and on Ideone.com but showing error there. any reason? I am writing my code here: what I am trying to do is to calculate primes of order…
user2088078
0
votes
1 answer

Haskell: How to find the number of integer solutions to equation for use in Sieve of Atkin?

I am currently trying to implement the Sieve of Atkin in Haskell In step 3 on the Wikipedia article on the Sieve of Atkin I need to find the number of Integer solutions to multiple equations. However my solution to the first of these equations (4x²…
0
votes
2 answers

C++ - Sieve of Atkin code optimizations

I was wondering if anyone had any suggestions on what I can do to improve the running speed of my code. I wrote a Sieve of Atkin function that returns a vector including all primes from [2, max] inclusive. Here is my code. void atkin_sieve (unsigned…
BigBerger
  • 1,765
  • 4
  • 23
  • 43
0
votes
1 answer

Calculating sum of prime number below 2 million by using Sieve of Atkin

I'm doing project Euler and I got this problem. I run the code in VS 2013 and the program crashes because of overflow. This is my method: void problem10() { long long int iter = 2, sum = 0; //Sieve of Atkin bool…
Trung Bún
  • 1,117
  • 5
  • 22
  • 47
0
votes
1 answer

C++ Sieve of Atkin Returning Several Composites

I have made my own implementation of the Sieve of Atkin in C++, it generates primes fine until about 860,000,000. Around there and higher the program begins to return several composites, or so I think. I have a variable inside the program the counts…
0
votes
1 answer

c++ Multiples of 5 in sieve of atkin implemenation

I'm solving a problem over at project euler which requires me to find the sum of all primes under 2 million. I tried to implement sieve of atkin and strangely it sets numbers like 65,85 as primes. I looked at the code and algorithm for over a a day…
0
votes
2 answers

Sieve of Atkin returns array... with invalid indices - Java

So I made a sieve of Atkin algorithm to generate primes (for Project Euler problems). It returns an array of primes (int[]) called primes. Problem is, whenever I try accessing that array from some index (I do so in my main method), it throws me a…
Bluefire
  • 13,519
  • 24
  • 74
  • 118
0
votes
4 answers

Print first 1 million primes in 1 sec with constraints program size 50000 bytes and limited Memory

I tried sieve of Eratosthenes: Following is my code: void prime_eratos(int N) { int root = (int)sqrt((double)N); bool *A = new bool[N + 1]; memset(A, 0, sizeof(bool) * (N + 1)); for (int m = 2; m <= root; m++) { if (!A[m]) { …
vijay
  • 2,034
  • 3
  • 19
  • 38
-1
votes
1 answer

value requires 1000000000 bytes, which is more than max-value-size

I am stuck with this problem on spoj.com http://www.spoj.com/problems/PRIME1/ After reading a bit about prime generation algorithms, I found that "Sieve of Atkins" is the fastest prime generation algorithm. I have partially implemented the algorithm…
Lakshmikant Deshpande
  • 826
  • 1
  • 12
  • 30
1
2