All Questions
9 questions
4
votes
2
answers
328
views
Counting primes less than n in Python
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...
2
votes
3
answers
1k
views
the 10001st prime number
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 ...
7
votes
2
answers
1k
views
Project Euler problem 50
I was just trying Project Euler problem 50.
The prime 41, can be written as the sum of six consecutive primes: 41
= 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that ...
3
votes
2
answers
1k
views
Sum of primes up to 2 million using the Sieve of Eratosthenes
I've solved question 10 on Project Euler using the Sieve of Eratosthenes, what can I do to optimize my code?
...
8
votes
1
answer
2k
views
Finding nth Prime using Python and Sieve of Eratosthenes
I'm currently working through the Project Euler Problems using HackerRank to evaluate the code and I'm stuck on the 7th Problem.
...
5
votes
3
answers
226
views
Snakes on a prime
The challenge is to find and print the largest palindrome prime under 1000.
...
4
votes
1
answer
117
views
Sieve of Eratosthenes solution for CodeEval
The code below takes integer n as input, and delivers a list of all primes up to integer n using the Sieve of Eratosthenes.
My question is, could you please help me optimize this code? Is it ...
7
votes
5
answers
1k
views
Project Euler #35 - Circular primes solution is slow
This is my code for project euler #35 (in Python):
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such ...
3
votes
4
answers
3k
views
Sieve of Eratosthenes: making it quicker
I was thinking about doing problem 23 of Project Euler. It includes the difficulty where you have to factorize primes. I had already done that in problems I solved earlier, but it was only necessary ...