Project Euler is a collection of mathematical programming problems of varying difficulty.

learn more… | top users | synonyms

2
votes
3answers
121 views

Is there any way to make my project Euler#14 solution faster?

I'm solving project euler problems and uploading my solutions to github. Some of my solutions are just based on math and are thanks to that very fast, but #14 is way too slow, and I have no idea how ...
3
votes
1answer
62 views

Lowest Common Multiple of 1 to n in Ruby

Project Euler problem 5 asks: What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? I'm learning Ruby by going through Project Euler problems, and ...
3
votes
1answer
99 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 ...
1
vote
3answers
93 views

Project Euler problem 37: truncatable primes

I am working on Project Euler problem 37 and I have the following program: #!/usr/bin/ruby -w require 'prime' h=11 y=0 x=0 while x < 11 if h.prime? == true boo = true f=0 ...
1
vote
1answer
58 views

Can this solution to Project Euler #15 be improved?

I'm not a C programmer, just wanted to make a fast solution to the problem. Here's my code: #include <stdio.h> #define SIZE 21 // grid size + 1 ...
6
votes
2answers
329 views

Speed up solution to Project Euler problem 75

I've been programming for a few months now, and have used Stack Overflow a great deal, but this is my first post. Anyway, I wrote this code for Project Euler problem 75, and was curious if anyone knew ...
3
votes
1answer
64 views

Quadratic Primes

This is one of the slightly trickier Project Euler Questions I have seen (Question 27) Considering quadratics of the form: n² + an + b, where |a| < 1000 and |b| < 1000 where |n| is the ...
4
votes
4answers
204 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 ...
5
votes
1answer
169 views

smallest number divisible by all numbers from 1 to 20? Project Euler question 5

I'm currently working my way through the questions on Project Euler and I am on question 5. Is this the best possible solution? Any suggestions welcomed! List<int> divisors = new ...
1
vote
1answer
85 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 ...
0
votes
1answer
62 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, ...
1
vote
2answers
70 views

Project Euler Problem #3 - Improve algorithm performance

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 ...
7
votes
1answer
220 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 : ...
2
votes
3answers
111 views

Project Euler - Shortening Problem 2

You might have read my question on shortening my code to a one-liner for Problem 1. So, I was wondering, is there any more tricks of the trade to shorten my Problem 2 solution: fib = [0, 1] final = 1 ...
3
votes
1answer
106 views

Project Euler Problem 1

This is my python solution to the first problem on Project Euler: n = 1 rn = 0 while n < 1000: if n%3 == 0 or n%5 == 0: rn += n n = n + 1 print(rn) I would like to find a way to ...
0
votes
3answers
117 views

How can this python code be improved?

I'm trying to become more proficient in Python and have decided to run through the Project Euler problems. In any case, the problem that I'm on (17) wants me to count all the letters in the English ...
2
votes
1answer
56 views

Can this small snippet of code be better written? It organizes a long string into a list of lists

This code loads the data for Project Euler problem 18, but I feel that there must be a better way of writing it. Maybe with a double list comprehension, but I couldn't figure out how I might do that. ...
2
votes
1answer
73 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 ? ...
4
votes
2answers
222 views

Any better way to solve Project Euler problem # 5

So, here's my attempt on Problem # 5 of Project Euler, which is looking quite clumpsy when seen first time. Is there any better way to solve this? Or any built-in library that already does some part ...
1
vote
3answers
71 views

Tips on projecteuler code optimization

I am working on projecteuler # 14, http://projecteuler.net/problem=14 and my code takes too long to run. Any tips, or hints for a beginner? Code: //////////////////////// /// ProjectEuler # 14/// ...
1
vote
3answers
291 views

Need a faster way to determine prime numbers than my algorithm

The problem I am solving is: "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 ...
0
votes
2answers
153 views

optimizing project euler #83 solution

I have solved the project euler problem 83 using uniform cost search. This solution takes about 0.6s to solve. I want to know if anyone can get the code to run relatively faster without changing the ...
3
votes
1answer
252 views

Golang solution to Project Euler problem #81

Below is a Go solution to the problem 81 in project euler using uniform cost search to build a search tree. It works on the toy small problem but on the 80x80 matrix it runs out of space. Could anyone ...
6
votes
2answers
141 views

Solving Project Euler problem #48 in Scala

I'm trying to learn some Scala and decided to try to tackle some Project Euler problems. For problem #48, coming from a Python background, my solution is the following one-liner: print ( (1 to ...
4
votes
2answers
157 views

Project Euler #9 in haskell

I am trying to teach myself haskell by means of project Euler i sovled problem #9 by means of this code which is on the brute force side I was wondering if there is a more elegant/haskell/efficient ...
2
votes
2answers
286 views

Python Code Review - Project Euler #12

I just figured out Project Euler problem #12. This the first one I've done in Python, so I'm putting my code out there to hopefully get some constructive criticism. If anyone is interested, would ...
8
votes
1answer
271 views

Help me make my Python code clearer

Here's my solution to Project Euler problem 40. import operator import math def levels(n): return 9 * n * 10 ** (n - 1) def face_value(i): def level_filler(i): n = 1 yield 1 ...
5
votes
3answers
385 views

Optimizing Code for Project Euler Problem 14

For Project Euler problem 14 I wrote code that runs for longer than a minute to give the answer. After I studied about memoization, I wrote this code which runs for nearly 10 seconds on Cpython and ...
4
votes
2answers
417 views

Project Euler problem 11 in python

My solution for project euler #11 in python. Possibly it can be improved. But other than improvements, I have 2 extra questions, more likely confessions, mostly because of my laziness: 1- Would it be ...
3
votes
2answers
196 views

A little scheme programming challenge

I am learning scheme to get something new from a programming language and this code below is the solution to Project Euler question 21 but the code runs 10x slower than the listed Python code when I ...
2
votes
1answer
217 views

Isn't this dynamic programming?

I was solving problem 18 and 67 on Project Euler and came up with an algorithm that actually goes through almost all the possibilities to find the answer in O(n) time. However, ProjecEuler claims ...
9
votes
2answers
2k views

Problem 5 on Project Euler

I just recently learned about Project Euler and have started doing the problems on there. I cleared problem 1 and 2, had no idea how to do 3 and 4, and started to do 5. I've seen the post regarding ...
0
votes
2answers
110 views

How do I add memoization to this problem? [closed]

Problem Starting in the top left corner of a 22 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 2020 grid? Solution Here is my ...
4
votes
2answers
232 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 ...
3
votes
1answer
133 views

Euler 2 : Simple Fibonacci

I'm just starting to experiment with F# (from a C# background). I think I'm starting to get into the right way of thinking, but this code still seems pretty awkward. Is there a better (more terse) ...
-2
votes
1answer
682 views

Project Euler Problem 13 [closed]

Hi. I'm a novice C programmer. I'm trying to solve problem 13 but I feel as if my solution isn't as elegant as it could be. Can you please help me by providing me with advice on how to solve this ...
1
vote
1answer
252 views

Connect graph from 2d array

I just completed project euler problem 18 which is a dynamic programming question through a graph of a triangle of numbers. The goal is to find the path from top to bottom of the triangle that has the ...
3
votes
2answers
151 views

Python vs. Java Runtime on Euler 22

On performing the following Euler problem, Python takes up less lines and runs faster (Python ~0.05s, Java ~0.3s on my machine). Could I optimize this Java code in any way? The problem is here ...
3
votes
6answers
2k 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: static void Main(string[] args) { const long ...
2
votes
2answers
1k views

Python Solution for Project Euler #2 (Fibonacci Sums)

I'm a fairly new programmer (just started yesterday!). I decided to tackle Project Euler #2 today, as I did #1 yesterday without many problems. I came up with what seems to me to be a working ...
4
votes
2answers
277 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, 719, 971.) The code takes about 30 ...
5
votes
1answer
215 views

Project Euler question 2 in CoffeeScript

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. fib = (x) -> return 0 if x == 0 return 1 if x == 1 ...
5
votes
4answers
532 views

Improving my solution to Project Euler problem #1?

I'm trying to compare my own implementation with another solution of ProjectEuler problem #1, which uses a list comprehension: module Progression1 (sumProgressions) where import Prelude ...
2
votes
2answers
260 views

Project Euler, #4: Incorrect Results on 7-digit numbers

I've got my answer working (up until a 7-digit answer is requested, anyway), and would like some help returning the correct answer speeding up the results I was thinking of storing the values of ...
2
votes
5answers
901 views

Critique my code for determining numeric palindromes

I am working on bettering my C# skills, and recently wrote this program to solve a projecteuler.net problem (Problem description: "A palindromic number reads the same both ways. The largest palindrome ...
8
votes
6answers
2k 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 int ...
1
vote
5answers
864 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 ...
7
votes
2answers
170 views

Project Euler problem 1 in Factor

I'm a complete beginner of Factor, but I just managed to solved Euler Problem #1 using it, and would love to have the code reviewed. Anything that can be improved? In particular I'm wondering if there ...
3
votes
1answer
119 views

How can I get this R code to pass the “1 minute” test for this Project Euler question?

I am attempting to learn R programming by going through the questions in Project Euler. The code below is my solution to problem 5 which asks for the smallest number that is evenly divisible by 1 ...
2
votes
2answers
277 views

Producing full list of Fibonacci numbers which fit in Int…

I am progressing through the problems listed at projecteuler.com as I learn Scala (my blog where I am covering this experience: fromjavatoscala.blogspot.com). I have written a function to produce all ...

1 2