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.

26 questions
31
votes
1 answer

Sieve of Atkin - Explanation and Java example

I have read about Sieve of Atkin on Wikipedia but the wiki is limited at the moment. I was looking for an explanation of Sieve of Atkin at a high level and an example in Java. Thanks.
Jash Sayani
  • 1,231
  • 3
  • 12
  • 17
23
votes
5 answers

Sieve of Atkin explanation

I am doing a project at the moment and I need an efficient method for calculating prime numbers. I have used the sieve of Eratosthenes but, I have been searching around and have found that the sieve of Atkin is a more efficient method. I have found…
marc lincoln
  • 1,385
  • 4
  • 20
  • 25
20
votes
2 answers

The Sieve of Atkin

I have been trying to learn algorithms for generating prime numbers and I came across Sieve of Atkin on Wikipedia. I understand almost all parts of the algorithm, except a few. Here are the questions: How are the three quadratic equations below…
Shiv
  • 461
  • 4
  • 8
10
votes
4 answers

Prime number hard drive storage for very large primes - Sieve of Atkin

I have implemented the Sieve of Atkin and it works great up to primes nearing 100,000,000 or so. Beyond that, it breaks down because of memory problems. In the algorithm, I want to replace the memory based array with a hard drive based array.…
WyomingGeezer
  • 157
  • 11
7
votes
6 answers

C#: Implementation of the Sieve of Atkin

I was wondering if someone here have a good implementation of the Sieve of Atkin that they would like to share. I am trying to implement it, but can't quite wrap my head around it. Here is what I have so far. public class Atkin :…
Svish
  • 138,188
  • 158
  • 423
  • 589
6
votes
2 answers

Segmented Sieve of Atkin, possible?

I am aware of the fact that the Sieve of Eratosthenes can be implemented so that it finds primes continuosly without an upper bound (the segmented sieve). My question is, could the Sieve of Atkin/Bernstein be implemented in the same way? Related…
K.Steff
  • 2,012
  • 3
  • 19
  • 24
5
votes
2 answers

Why does my naive implementation of the Sieve of Atkins exclude 5?

I wrote an extremely naive implementation of the Sieve of Atkin, based on Wikipedia's inefficient but clear pseudocode. I initially wrote the algorithm in MATLAB, and it omits 5 as a prime number. I also wrote the algorithm in Python with the same…
Ricardo Altamirano
  • 12,617
  • 20
  • 67
  • 104
3
votes
0 answers

Highly Factorized Sieve of Eratosthenes

Just for fun, I'm trying to implement the pseudocode from this StackOverflow answer for the highly factorized Sieve of Eratosthenes in C++. I can't figure out why my code returns both prime and non-prime numbers. Am I implementing these for loops…
tn3rt
  • 240
  • 2
  • 13
3
votes
1 answer

Why is my implementation of the Sieve of Atkin overlooking numbers close to the specified limit?

My implementation of Sieve of Atkin either overlooks primes near the limit or composites near the limit. while some limits work and others don't. I'm am completely confused as to what is wrong. def AtkinSieve (limit): results = [2,3,5] sieve =…
imperialdogma
  • 43
  • 1
  • 7
3
votes
1 answer

C++ Sieve of Atkin overlooks a few prime numbers

Recently I've been working on a C++ prime generator that uses the Sieve of Atkin ( http://en.wikipedia.org/wiki/Sieve_of_atkin ) to generate its primes. My objective is to be able to generate any 32-bit number. I'll use it mostly for project euler…
Axel Magnuson
  • 1,142
  • 1
  • 9
  • 25
3
votes
2 answers

Sieve of Atkin malfunctioning for very high limits

I am attempting to solve Project Euler problem 10 where the user is asked to calculate the sum of all the primes less than two million. I've written the following by studying the pseudocode on Wikipedia but the answer it generates seems to be…
user360907
2
votes
4 answers

C#: How to make Sieve of Atkin incremental

I don't know if this is possible or not, but I just gotta ask. My mathematical and algorithmic skills are kind of failing me here :P The thing is I now have this class that generates prime numbers up to a certain limit: public class Atkin :…
Svish
  • 138,188
  • 158
  • 423
  • 589
1
vote
1 answer

Python Implementation of the Sieve of Atkin

My code works to give most primes, however it still include 1 and misses some numbers: 23 and 47 (when calculating prime numbers under 100). For some reason it includes 91, any ideas why?? I have been using the Wikipedia instructions for the Sieve…
Tom
  • 724
  • 5
  • 19
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
1
2