Skip to main content

Questions tagged [sieve-of-eratosthenes]

The Sieve of Eratosthenes is a prime-finding algorithm developed by the ancient Greek mathematician Eratosthenes. It works by writing down as many numbers as needed and then, traversing from lowest to highest, cross out all multiples of a number, beginning with 2. The numbers that remain are considered prime and the lowest of it will be used for the next run.

5 votes
3 answers
254 views

I have implemented Sieve of Eratosthenes with Wheel Factorization in C++ again, this time using a bigger wheel and much more complicated C++ syntax, to familiarize myself with C++ and see how fast I ...
Ξένη Γήινος's user avatar
4 votes
2 answers
240 views

I've implemented this version of the Sieve of Eratosthenes in Rust, with inputs. I'm mostly pleased with it, but want to know if the input logic can be simplified, and if the sieve itself can be ...
Vessel's user avatar
  • 345
1 vote
0 answers
65 views

As an exercise I've implemented a segmented Sieve of Eratosthenes in OCaml. It does require OCaml 5.2.0 or later as I've utilized Dynarray to handle my array of ...
Chris's user avatar
  • 5,926
4 votes
2 answers
775 views

I have this code, which is a pseudo-Sieve of Eratosthenes for generating primes: ...
Ari Fordsham's user avatar
8 votes
3 answers
2k views

I have written a completely working C++ program for the first time, and I have managed to compile it. I have decided to learn C++ and I have written a C++ program to familiarize myself with C++, this ...
Ξένη Γήινος's user avatar
3 votes
0 answers
182 views

Related This is a Python script that generates images using prime numbers up to a given positive integer, it generates prime numbers using the Sieve of Eratosthenes with some rudimentary Wheel ...
Ξένη Γήινος's user avatar
3 votes
1 answer
156 views

Using Sieve of Eratosthenes, I created a function that returns a vector of primes up to given limit. ...
manungsa's user avatar
  • 107
2 votes
1 answer
353 views

I state that I am not an expert and that certainly the code can be improved. I made this prime number sieve to be able to handle large numbers. The basic idea is to write a number p=r+bW*k where r is ...
user140242's user avatar
0 votes
2 answers
768 views

This is the next development for the Sieve of Eratosthenes algorithm, where all the multiples of 2,3 and 5 are eliminated, which will not take any memory or time. As my last question Improved Sieve of ...
Ahmed Diab's user avatar
7 votes
7 answers
4k views

How can I get to a perfect coding for this algorithm? I made the mathematical theorem, which is a development of the Sieve of Eratosthenes algorithm. I might use some help in coding. You can find the ...
Ahmed Diab's user avatar
4 votes
2 answers
388 views

I implemented (a refinement of) the Sieve of Eratosthenes for counting primes less than a given number n. This is a coding exercise from LeetCode. The class Solution...
user avatar
4 votes
2 answers
764 views

Hello I made a sieve of Eratosthenes algorithm on x86 assembly using NASM. The highest number it can take is about 2 million and it takes like 2 seconds to complete. Here's the code: ...
user259137's user avatar
2 votes
4 answers
1k views

Problem description: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? Prime number: A prime number is a whole ...
Amir Motefaker's user avatar
2 votes
1 answer
206 views

after looking at the pseudocode for the Sieve of Eratosthenes on wikipedia I tried implementing a similar version using F#. The code runs just fine, that is, it returns all prime numbers up until a ...
Antônio Salomão's user avatar
5 votes
1 answer
256 views

Problem I have a project in which I implemented variants of the Sieve of Eratosthenes as well as benchmarking and profiling harnesses for these (which can be ran with ...
nicoty's user avatar
  • 329

15 30 50 per page
1
2 3 4 5
13