Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
227 views

I've coded up the Self Initializing Quadratic Sieve (SIQS) in Python, but it has been coded with respect to being as fast as possible in PyPy(not native Python). Here is the complete code: import ...
J. Doe's user avatar
  • 1,429
1 vote
0 answers
154 views

I am attempting to write a Sieve email filter using the "body", "regex", and "variables" extensions. Following is a very simplified version of the filter to test/...
Matthew B's user avatar
  • 172
3 votes
1 answer
129 views

I'm trying to use the Sieve of Eratosthenes' algorithm in Haskell to generate a stream of primes but the code doesn't seems to work. This is the main idea. The main idea is derived from our functional ...
teo's user avatar
  • 33
2 votes
1 answer
298 views

I'm trying to write code that is done over a lot of values, and my code is doing a ton of extra work. I'm not even quite sure mathematically how to describe the values I want to skip, because as i ...
guest4308's user avatar
  • 167
0 votes
2 answers
117 views

I'm making the sieve of erasthostenes in c. I have programmed it in other languages before but I never encountered this problem. Here's my algorithm: #include <stdio.h> #include <stdbool.h>...
Simon Klyvare's user avatar
1 vote
1 answer
225 views

I made this segmented sieve that uses wheel factorization. Here you find the explanation. By setting the wheel size to 210 and using a segment vector uint8_t of size 277140 = 6 * (11 * 13 * 17 * 19 + ...
user140242's user avatar
-1 votes
1 answer
94 views

I found this code that seems to be the non-optimal version of the Sieve of Erastothenes, it gets the N first prime numbers into an array. private IntPredicate p = x -> true; private int[] primes(...
Brando Jeanpier's user avatar
1 vote
1 answer
207 views

A recent Q&A entry showcased the following primes generating code from SICP, using lazy streams: (define (sieve stream) (cons-stream (stream-car stream) (sieve (stream-filter (...
Will Ness's user avatar
  • 71.6k
0 votes
0 answers
125 views

In cases of low memory available I thought it was possible to implement a double-segment sieve to find prime numbers in a neighborhood of n. In practice, a segmented sieve has dimension dim_seg_1 for ...
user140242's user avatar
3 votes
1 answer
227 views

I learned an algorithm called "linear sieve" https://cp-algorithms.com/algebra/prime-sieve-linear.html that is able to get all primes numbers smaller than N in linear time. This algorithm ...
Dachuan Huang's user avatar
4 votes
2 answers
564 views

Based on this Python answer by Will Ness, I've been using a JavaScript adaptation for the postponed sieve algorithm from that answer: function * primes() { yield 2; yield 3; yield 5; ...
vitaly-t's user avatar
  • 26.1k
1 vote
0 answers
307 views

I'm doing a project on Sieve of Atkins and I was exploring why this algorithm was created. From what I understood was that it was a way of finding prime numbers and it ran faster than Sieve of ...
CrashMan123's user avatar
1 vote
2 answers
526 views

I am working on coming up with a solution for coming with a list of prime numbers using the Sieve of Eratosthenes. So the program is supposed to find prime numbers up to a specific number "n"...
user15155886's user avatar
1 vote
1 answer
367 views

Unlike the traditional sieve of Eratosthenes: n=10000000 sieve = [True] * n for i in range(3,int(n**0.5)+1,2): if sieve[i]: sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1) sieve=[2] + [i for ...
user140242's user avatar
-2 votes
1 answer
140 views

I am currently going through all of the algorithms we learned about in a certain class, trying to understand what each does and how. However, I am a bit clueless about a certain line in our ...
CodeAche's user avatar
4 votes
0 answers
178 views

I was given 2 different algorithms written in Haskell aimed to generate the first k primes. As the title suggests, they are the Sieve of Eratoshenes and Euler. I am trying to understand why Euler ...
Toby's user avatar
  • 61
5 votes
5 answers
2k views

Sieve of Eratosthenes memory constraint issue Im currently trying to implement a version of the sieve of eratosthenes for a Kattis problem, however, I am running into some memory constraints that my ...
Fredrik HD's user avatar
0 votes
0 answers
20 views

like for 1 to 10 no of such digits are 3.Because only 6,8 and 10 have no. of factor 4 (including 1 and the number). We can not use SIEVE because we can not construct an array of Length 10^12. Share ...
SUBHRAJYOTI HAIT's user avatar
4 votes
3 answers
148 views

And how can I correct them to work? I am trying to optimize my sieve per previous suggestions, but in both instances the code breaks: Incrementing j = j + ( i * 2) will break the code. Obviously I'm ...
jennifer's user avatar
  • 772
1 vote
0 answers
109 views

So I have been trying to implement the quadratic sieve and I did step 1 which is(in code): f = 44 b = ceil(sqrt(n)) factorBase = [i for i in genPrimes(f) if jacobi(n, i) == 1] t = [modInverse(n, p) ...
Aayush Lakhotia's user avatar
3 votes
1 answer
1k views

I am trying to make a parallel implementation of the Sieve of Eratosthenes. I made a boolean list which gets filled up with true's for the given size. Whenever a prime is found, all multiples of that ...
SD33N's user avatar
  • 88
0 votes
0 answers
362 views

We are given an array. array size <= 1e4. 1 <= A[i] <= 1e18. We can run a double loop to find gcd of each possible pair. Is there any optimized algorithm?
user avatar
0 votes
0 answers
52 views

Here is the link to the problem -> PRIME1 It asks us to print all the prime numbers between two numbers m and n I used segmented sieve to solve the problem. Stored all the primes till sqrt(10^9) and ...
Sri Harsha's user avatar
1 vote
2 answers
50 views

I implemented a recursive Sieve of Erasthotenes, which, from the debug statements used, appears to work, but returns None. The code with the debug statements looks like this: def sieb2 (iterable, ...
E. Staikov's user avatar
-3 votes
1 answer
53 views

My block of code runs, but whenever I type in input, it returns Thread 1: EXC_BAD_ACCESS (code=1, address=0x4). I'm fairly new to coding, and was wondering what's wrong. #include <vector> #...
Griffin Wong's user avatar