Project Euler Tricks

Discussions center on efficient mathematical solutions to Project Euler problems, like using n(n+1)/2 for sums instead of loops, brute force critiques, and related puzzles such as primes and digits of e.

āž”ļø Stable 0.5x Science
2,964
Comments
20
Years Active
5
Top Authors
#9273
Topic ID

Activity Over Time

2007
12
2008
39
2009
82
2010
135
2011
159
2012
176
2013
207
2014
126
2015
203
2016
112
2017
182
2018
136
2019
187
2020
154
2021
210
2022
212
2023
198
2024
213
2025
217
2026
4

Keywords

NET VB.NET tanyakhovanova.com VB ii.html blogspot.com jsfiddle.net github.com CRT replpad.com print 10 double dp digit numbers sum long long number brute

Sample Comments

isaacremuant • Jan 25, 2025 • View on HN

I think the joke is that it's hardcoded. It's definitely easier to implement it for n numbers yourself.

amadeuspagel • May 25, 2022 • View on HN

- project euler #7: <a href="https://replpad.com/Ly8gcHJvamVjdCBldWxlciAjNwoKZnVuY3Rpb24gaXNQcmltZShuKSB7CiAgICBmb3IgKGkgPSAyOyBpIDw9IChuIC8gaSk7IGkrKykgewogICAgICAgIGlmIChuICUgaSA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gZmFsc2UKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZQp9CgovLyBpc1ByaW1lKDIpCi8vIGlzUHJpbWUoMykKLy8gaXNQcmltZSg0KQovLyBpc1ByaW1lKDUpCgpmdW5jdGlvbiBudGhQcmltZShuKSB7CiAgICBpZiAobikgewogICAgICAgIGxldCBwb3NpdGlvbiA9IDAKICAgICAgICBmb3IgKGxldCBpID0gMjs7IGkrKykgewogICAgICAgICAg

zsiciarz • Jun 5, 2014 • View on HN

This can be helpful in Project Euler challenges.

saagarjha • Jun 1, 2025 • View on HN

Read this to instantly annihilate Project Euler problems

meiji163 • May 16, 2021 • View on HN

What's amusing is that multiplying integers with periodic digits is much faster using this method

strangecasts • Jun 19, 2016 • View on HN

Just wait until you hear how much power is being spent on finding multiples of 3 and 5!

ggambetta • Jul 17, 2020 • View on HN

This is primary school arithmetic, not programming :(

CyberRabbi • Aug 14, 2021 • View on HN

I’m disturbed that he needed a for loop to compute 100*(1-0.9^10)

dreamcompiler • Sep 15, 2021 • View on HN

The way you add the integers up to n isn(n+1)/2.Fixed that for you. No loops, and it's exact. Pick a better example.

reinhardt • Aug 7, 2011 • View on HN

Spoiler: for small values of infinite apparently.. 1720 in this case