TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Project Euler's 500th problem

254 pointsby bhaumikover 10 years ago

12 comments

jacquesmover 10 years ago
I absolutely love project Euler. The math on the harder problems is way over my head but it is still my go-to site whenever I want to learn a new language. By the time you&#x27;ve done a bunch of them you&#x27;ll be more than underway in understanding the territory and in a much better position to understand tutorials (which inevitably are written by experts in the language and usually make a ton of assumptions).<p>Alternating between project Euler, a book (or two), back to project Euler for a bit is a very fast school, and you determine how fast you can pace yourself.
评论 #8977942 未加载
评论 #8977933 未加载
评论 #8977881 未加载
评论 #8978378 未加载
评论 #8978406 未加载
评论 #8980284 未加载
评论 #8979491 未加载
评论 #8978096 未加载
bhaumikover 10 years ago
&quot;Saturday 31st of January Project Euler will reach a major milestone with the publication of our 500th problem. To celebrate this the team has composed a special problem in which the number 500 occurs repeatedly. In addition we&#x27;re going to publish an ordinary problem simultaneously as problem 501. Both problems are published at 13:00 London time.<p>We invite all members to participate in our problem solving party. As celebrator of this jubilee we&#x27;re allowed to ask the participants for a present. Well, here&#x27;s our wish: please don&#x27;t share any information about our party and the dishes we&#x27;re serving you outside the fora dedicated to our dishes after your meal. This to allow those that are late to the party to consume our dishes undisturbed by premature revelations about what we are serving.&quot;<p><a href="https://projecteuler.net/news" rel="nofollow">https:&#x2F;&#x2F;projecteuler.net&#x2F;news</a>
kyberiasover 10 years ago
For Project Euler enthusiasts: here&#x27;s a similar site focused on bioinformatics that I&#x27;ve found very very good: <a href="http://rosalind.info/" rel="nofollow">http:&#x2F;&#x2F;rosalind.info&#x2F;</a><p>Also suitable for learning new languages (and bioinformatics).<p>The implementation of the site is awesome.
评论 #8978298 未加载
bhaumikover 10 years ago
If you&#x27;re interesting in the birth, inspiration and pedagogy behind Project Euler, I recommend this article [1].<p><i>And it&#x27;s an effective teacher because those problems are arranged like the programs in the ORIC-1&#x27;s manual, in what Hughes calls an &quot;inductive chain&quot;:<p>The problems range in difficulty and for many the experience is inductive chain learning. That is, by solving one problem it will expose you to a new concept that allows you to undertake a previously inaccessible problem. So the determined participant will slowly but surely work his&#x2F;her way through every problem.</i><p>[1]<a href="http://www.theatlantic.com/technology/print/2011/06/how-i-failed-failed-and-finally-succeeded-at-learning-how-to-code/239855/" rel="nofollow">http:&#x2F;&#x2F;www.theatlantic.com&#x2F;technology&#x2F;print&#x2F;2011&#x2F;06&#x2F;how-i-fa...</a>
dhbradshawover 10 years ago
After you solve a problem Project Euler lets you browse through a giant list of solutions by those who have gone before. It&#x27;s really fun to see and compare all the different approaches.<p>If I could do one thing to augment the project I would make it possible to filter previous solutions by language and&#x2F;or author.<p>For example, if I&#x27;m learning rust, I would love to see all the rust solutions right there together.
ipsinover 10 years ago
Happy 500th!<p>If you&#x27;ve never tried Project Euler, it&#x27;s a great way to learn new mathematical concepts, sequences, dynamic programming and other algorithms.<p><a href="https://projecteuler.net/problem=368" rel="nofollow">https:&#x2F;&#x2F;projecteuler.net&#x2F;problem=368</a> was one of my favorites, because it involved turning an algorithm described in a paper into code.<p>I don&#x27;t consider this a spoiler for problem #500, but if you&#x27;re counting the number of divisors, you&#x27;ll need this function: <a href="http://oeis.org/wiki/Number_of_divisors_function#Formulae_for_the_number_of_divisors_function" rel="nofollow">http:&#x2F;&#x2F;oeis.org&#x2F;wiki&#x2F;Number_of_divisors_function#Formulae_fo...</a><p>As an example, 120 = 2^3 * 3^1 * 5^1<p>number of divisors of 120 =&gt; (3+1)<i>(1+1)</i>(1+1)<p>Even if you don&#x27;t solve it, exploring the problem is a fun afternoon for a person with a computer.
评论 #8977905 未加载
评论 #8978150 未加载
florianletschover 10 years ago
I love Project Euler. In this thread I&#x27;ve found references for similar projects but focussed more on actual coding (http:(<a href="http://oj.leetcode.com" rel="nofollow">http:&#x2F;&#x2F;oj.leetcode.com</a>) or on BioInformatics (<a href="http://rosalind.info/problems/locations/" rel="nofollow">http:&#x2F;&#x2F;rosalind.info&#x2F;problems&#x2F;locations&#x2F;</a>).<p>Any chance you guys know of a similar project for Computer Vision or general AI topics?
评论 #8979793 未加载
评论 #8988795 未加载
imslavkoover 10 years ago
This is a nice little problem, I had fun solving it.<p>For those of us who are familiar with TopCoder, CodeForces or, perhaps, ACM ICPC, this should be daily bread and butter on prime numbers and data structures :)<p>Here is my solution if you are curious: <a href="https://gist.github.com/Slava/74276f5b7889a1d68a71" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;Slava&#x2F;74276f5b7889a1d68a71</a> - computes the result in 400ms<p>Edit: hah, looking at the problems discussion board I took a very bruteforce approach, other people solved utilizing math, I used priority_queue for no particular reason :)
joshstrangeover 10 years ago
I was only recently introduced to Project Euler but already I&#x27;m addicted. I&#x27;ve got a folder where I&#x27;ve named each solution as pXXX.ext and try solving the problems in multiple different languages. I refuse to move on to a new problem until I&#x27;ve solved the previous one (I don&#x27;t solve every problem in multiple languages. Instead I&#x27;ve been using it to learn&#x2F;play with languages here and there I don&#x27;t really know).<p>Congrats to Project Euler on their 500th problem!
评论 #8978394 未加载
评论 #8978259 未加载
goaliecaover 10 years ago
Every couple of years I get addicted for a few weeks. Love the effort these guys put into the problems.
评论 #8979486 未加载
评论 #8978116 未加载
sargunover 10 years ago
I was asked this question at an interview at $COMPANY last week. Heh. I failed pretty miserably.
fishtasticover 10 years ago
Screamed at JavaScript for failing at big integer multiplications. Got it after rewriting in python. Here is my poorly written explanation.<p>--------- MAJOR SPOILERS ---------<p>Let&#x27;s multiply unique prime numbers and count their factors.<p><pre><code> n Number of factors 2 2 (1, 2) 2x3 4 (1, 2, 3, 6) 2x3x5 8 2x3x5x7 16 </code></pre> Notice that each time you add a new prime number, the factor count doubles<p>i.e. 2x3x5x...x500500th prime will have 2^500500 factors<p>The 500500th prime is 7376507 (thanks to wolframalpha), and it&#x27;s not very big.<p>We can easily get the product of the above with 500500 multiplications while modding result of each step by 500500507 to get an answer.<p>Except that the product of first 500500 primes isn&#x27;t the smallest number containing 2^500500 factors. This can be made smaller.<p>Observe that<p><pre><code> (2x3x5x...x500499th prime)x2 </code></pre> has<p><pre><code> 2^500499 + 2^500498 factors. </code></pre> This is because with the extra 2 we added, it produces additional factors with existing factors that are a multiples of 2.<p>Continuing with this, we see that<p><pre><code> (2x3x5x...x500499th prime) x (2 x 2) </code></pre> has<p><pre><code> 2^500499 + 2^500498 + 2^500498 = 2^500500 factors. </code></pre> This is a better solution, since 2x2 is smaller than the 500500th prime.<p>If we want continue doubling factor count by multiplying 2s, we will need to multiply by 2x2x2x2 next, and 2^8 after, which becomes inefficient quickly. Instead, why not use 3? Multiplying (2x3x5x...x500499th prime) by (3 x 3) also doubles the factor count.<p>So at this point, we think about doubling factor count and the ways we can do it. Out options are<p>&lt;1&gt;. Multiply by a prime that we have never used so far<p>&lt;2&gt;. Multiply by an existing prime k + 1 times, where k is the number of times it has been used<p>We repeat this 500500 times, using rule &lt;1&gt; and &lt;2&gt; (which can be generalized to one rule) and the result is the final answer.<p><pre><code> factor count n 2 2 4 2*3 &lt;1&gt; 8 2*3*2*2 &lt;2&gt; 16 2*3*2*2*5 &lt;1&gt; 32 2*3*2*2*5*7 &lt;1&gt; 64 2*3*2*2*5*7*3*3 &lt;2&gt; 128 2*3*2*2*5*7*3*3*11 &lt;1&gt; </code></pre> For 16 factors the number works out to be 120 (just like the example!). For numbers shown in the questions, sieving the prime takes some time, I also found it helpful to use a binary heap for speeding up finding the next smallest factors.
评论 #8980538 未加载