Using Lean or other programmable proof assistants to solve Project Euler is the inevitable collision of two autisms. In particular, using Lean to prove that you have the correct solution, just making a Lean program that prints out the correct solution is likely now trivial as of 2025 by asking an LLM to port a Python solution to the new language.
Some efforts:
- github.com/mfornet/project-euler-lean Attempts proofs, but only did Project Euler problem 1 :-)
- github.com/pcpthm/pe solved the first 50, but as stated on the README itself, no proofs, so boring
- unreasonableeffectiveness.com/learning-lean-4-as-a-programming-language-project-euler/ solves 4, but no proofs
Mentions:
- Alex J. Best (Jun 29 2022 at 14:20) on the Lean Zulip mentions:That dude was actually working at harmonic.fun as of 2025, bastard.
It would also be very interesting to collect verified fast Project Euler solutions for Lean 4 at some point, this would simultaneously work out the compiled speed and the mathematics libraries which would be fun.
- codeforces.com/blog/entry/124615
In other proof assistants, therefore with similar beauty:
- Coq
- github.com/airobo/Project-Euler-in-Coq: 1 and 2 with proofs
Repositories of numerical solutions:
Repositories of code solutions:
- euler.stephan-brumme.com/ large number of solutions in C++, stopped around 600. Informal permissive license, e.g. at: euler.stephan-brumme.com/243/Asked for a more formal open license at: github.com/stbrumme/euler/issues/7All of my solutions can be used for any purpose and I am in no way liable for any damages caused.
- www.ivl-projecteuler.com/home 330+ solutions in Python as of 2025. Random looking problem selection. On GitHub: github.com/igorvanloo/Project-Euler-Explained under Unlicense license, a public domain license.
- www.nayuki.io/page/project-euler-solutions. Large number of solutions, mostly in Java and Python primarily but also Mathematica and Haskell sometimes. Proprietary license.
Repositories with hints but no solutions:
Project Euler problems typically involve finding or proving and then using a lemma that makes computation of the solution feasible without brute force. There is often an obvious brute force approach, but the pick problem sizes large enough such that it is just not fast enough, but the non-brute-force is.
news.ycombinator.com/item?id=7057408 which is mega high on Google says:
I love project euler, but I've come to the realization that its purpose is to beat programmers soundly about the head and neck with a big math stick. At work last week, we were working on project euler at lunch, and had the one CS PhD in our midst not jumped up and explained the chinese remainder theorem to us, we wouldn't have had a chance.
In many cases, the efficient solution involves dynamic programming.
There are also a set of problems which are very numerical analysis in nature and require the approximation of some real number to a given precision. These are often very fiddly as I doubt most people can prove that their chosen hyperparameters guarantee the required precision.
Many problems ask for solution modulo some number. In general, this is only so that C/C++ users won't have to resort to using an arbitrary-precision arithmetic library and be able to fit everything into
uint64 instead. Maybe it also helps the judge system slightly having smaller strings to compare. The final modulos usually don't add any insight to the problems.Bibliography:
Saw this one mentioned on some Project Euler forum threads.
Nice motto, knowledge olympiads:
Serious mathematics for serious high-school students: There is more to mathematics than competitions.
TODO none? Seriously?
Unlisted articles are being shown, click here to show only listed articles.