Tagged Questions
7
votes
1answer
614 views
Project Euler 407: Is there any more optimal way to solve this idempotent equation (modulo n ring)?
Project Euler problem 407:
If we calculate a2 mod 6 for 0 ≤ a ≤ 5 we get: 0, 1, 4, 3, 4, 1.
The largest value of a such that a2 mod 6 = a is 4.
Let's call M(n) the largest value of a < n ...
7
votes
2answers
89 views
Largest Prime Factor redux
There have been a number of questions asking for comments on code for the Project Euler problem to compute the largest prime factor of a number. A primary intent of this task is to find the factor as ...
10
votes
1answer
292 views
x64 Assembly - checking for largest prime factor
Using x64 assembly, I solved the Largest Prime Factor problem on Project Euler.
The problem is as follows:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of ...
2
votes
3answers
200 views
Project Euler #12 in C++ - highly divisible triangular number
Project Euler Problem 12 asks (paraphrased):
The nth triangular number Tn = 1 + 2 + … + n. T7 = 28 has 6 divisors (1, 2, 4, 7, 14, 28). What is the first Tn to have over 500 divisors?
After ...
5
votes
3answers
78 views
Calculating the ranks of classmates' exam grades
The questions from hackerearth:
Geeko is in worry now because an exam is coming up and he has to know
what rank he can get on exams. So he goes back into the the school records
and finds the ...
4
votes
1answer
148 views
Largest Prime Factor
I'm trying to learn Python by working my way through problems on the Project Euler website. I managed to solve problem #3, which is
What is the largest prime factor of the number 600851475143 ?
...
5
votes
4answers
624 views
Any better way to solve Project Euler Problem #5?
Here's my attempt at Project Euler Problem #5, which is looking quite clumsy when seen the first time. Is there any better way to solve this? Or any built-in library that already does some part of the ...
17
votes
5answers
852 views
Count distinct primes, discarding palindromes, in under 2 seconds
Problem Statement
Generate as many distinct primes P such that reverse (P) is also prime
and is not equal to P.
Output:
Print per line one integer( ≤ 1015 ). Don't print more than
...
1
vote
4answers
1k 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 ...
8
votes
8answers
923 views
Project Euler #3 - largest prime factor
I was going through the Project Euler problem #3 and made a program to solve it. The problem is as follows:
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest
prime factor of ...
6
votes
1answer
82 views
Make Project Euler 27 solution idiomatic Ruby
I learned to program in Java and C# and in my free time I am using Ruby because it is fun. Unfortunately I have the feeling that I write Ruby code like I am making Java or C# code. I have learned to ...
2
votes
1answer
64 views
Project Euler 27 - Quadratic Primes
Project Euler problem 27
I decided to try simple brute force, and it worked surprisingly quickly. How can this be optimized?
...
10
votes
3answers
848 views
7
votes
5answers
484 views
Ten thousand and first prime checker takes a very long time
I am attempting problem 7 on Project Euler. I have come up with this solution which works fine for finding smaller nth prime numbers, but really lags when it comes to higher nth prime numbers. I am ...
5
votes
6answers
310 views
Speeding up my implementation of Project Euler #3
Project Euler problem 3 asks for the largest prime factor of 600851475143.
I have gone from 96 lines to 17 lines taking hits at this one. This is what I am left with after all of that effort:
...
2
votes
1answer
176 views
Why is one prime number function hugely faster than another? [closed]
I've found this excellent prime number module file from here as I work through the Project Euler problems, and I'm trying to fully understand the code and the maths behind it.
I've come to a hitch on ...
2
votes
3answers
738 views
Project Euler Problem 7: Find 10001st prime number
I was able to complete the problem, but I would like to improve my code and make it more idiomatic.
Here is the challenge description:
Problem 7 - 10001st prime
By listing the first six ...
10
votes
3answers
207 views
Project Euler “Largest prime factor” (#3) in Java
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
I wrote the following code with help of some Java 8, I'll explain the equivalent ...
1
vote
4answers
3k views
Need a faster way to determine largest prime factor
Project Euler problem 3 asks:
What is the largest prime factor of the number 600851475143?
The first step I took is to determine the highest value number I should be looking at as a possibility ...
5
votes
1answer
56 views
Project Euler #41 - pandigital prime
I've written a solution to Euler 41:
We shall say that an n-digit number is pandigital if it makes use of
all the digits 1 to n exactly once. For example, 2143 is a 4-digit
pandigital and is ...
2
votes
3answers
505 views
Project Euler Problem #3 - largest prime factor
I have began doing the problems found on Project Euler and have just solved problem 3. However, I feel as if my code is very long and too brute-force. I was hoping somebody could give it a look and ...
3
votes
3answers
536 views
Smallest prime factor of a large number (using BigInteger)
I'm working on a Project Euler problem and am trying to get the smallest prime factor of a BigInteger:
...
7
votes
2answers
516 views
Checking for circular primes - Project Euler Problem 35
I have been trying to solve Project Euler problem number 35. The problem is to find:
How many circular primes are there below one million?
A circular prime is a prime where all the rotations of ...
11
votes
4answers
406 views
Suggestions for improvement on Project Euler #7
Here is a solution for Project Euler Problem #7.
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 10,001st prime number?
I've ...
5
votes
3answers
557 views
Summation of primes takes forever
Project Euler Problem 10 asks: "What is the sum of all prime numbers below 2 million?"
How do I speed up my code? It's taking forever and I have never gotten the answer. However, I am sure that my ...
0
votes
1answer
29 views
Caml light and finding the prime factors
I wrote the following Caml light code to find prime factors of a number (part of an early Project Euler question).
Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29.
...
3
votes
3answers
229 views
How Pythonic is my Project Euler #5? (LCM of [1, 2, …, 20])
I have implemented a solution to Project Euler problem 5:
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive ...
3
votes
2answers
108 views
Attempting to efficiently compute the largest prime factor
As per the help, here's what I'm looking for from this post: best practice and practical advice about (what I think is describable as) buffering the output of a function.
So I'm working on the third ...
1
vote
3answers
224 views
Project Euler problem 37: truncatable primes
I am working on Project Euler problem 37 and I have the following program:
...
4
votes
4answers
606 views
Sum of primes less than 2,000,000
I have been attempting the questions at Project Euler and I am trying to find the sum of Primes under two million (question 10)
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the ...
3
votes
1answer
97 views
Quadratic Primes
This is one of the slightly trickier Project Euler Questions I have seen (Question 27)
...
1
vote
1answer
96 views
Optimizing code for project-euler p#23
I'm working on project euler's problem #23, wich is
Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers
So I came up with this algorithm. Find ...
8
votes
1answer
429 views
Project Euler #3 - how inefficient is my code?
So I am essentially a complete newbie to programming, and have been attempting to learn Python by completing the Project Euler problems. I haven't gotten very far, and this is my code for problem #3 :
...
0
votes
1answer
100 views
Project Euler 10: Summation of primes in Go
Here is my first try at googles Go language, trying to solve Eulers Problem 10:
http://projecteuler.net/problem=10
Any suggestions on the style and usage (best practice) of Go?
One more thing, ...
3
votes
6answers
4k views
Find the largest Prime Factor of the number 600851475143
I am trying to complete this challenge, which is to find the Find the largest Prime Factor of the number 600851475143.
My current solution is below:
...
10
votes
6answers
3k views
Sum of all primes under 2 million
I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million in c/c++. Im using the following function to check if each number is prime
...
4
votes
2answers
284 views
Improving runtime of prime generation
I just answered the question on project euler about finding circular primes below 1 million using python. My solution is below. I was able to reduce the running time of the solution from 9 seconds to ...
4
votes
2answers
408 views
Euler 35 - python solution taking too long
Here is my solution for Project Euler 35. (Find the number of circular primes below 1,000,000. Circular meaning all rotations of the digits are prime, i.e. 197, ...