In Problem 146 of Project Euler we are working with primes again, and some quite big ones even. The problem reads The smallest positive integer n for which the numbers n2+1, n2+3, n2+7, n2+9, n2+13, and n2+27 are consecutive primes is 10. The sum of all such integers n below one-million is 1242490. What is the sum of all such integers n below 150 million? At first […]

Continue reading...Saturday, February 2, 2013

With a little help from Wikipedia I found Problem 134 of Project Euler rather easy to solve. Well it was easy after solving some issues I had with integer overflows and several other bugs. But anyway, the problem readsIn fact, with the exception of p1 = 3 and p2 = 5, for every pair of consecutive primes, p2 > p1, there exist values of n for which the last digits are formed by p1 and n is divisible by p2. Let S be the smallest of these values of n.Find ΣS for every pair of consecutive primes with 5 ≤ p1 ≤ 1000000.Based on the problem description it is rather easy to formulate this as linear congruence and then all we need to do, is to figure out how to solve that.

Continue reading...Saturday, January 26, 2013

Problem 133 of Project Euler is a continuation of Problem 132 and Problem 129 in which we are supposed to find the some prime numbers which are not factors of R(10n) for any n. In fact the problem readsFind the sum of all the primes below one-hundred thousand that will never be a factor of R(10n).I have found two methods for solving this. Both build upon the same principle which I will present first...

Continue reading...Saturday, January 19, 2013

In problem 132 of Project Euler we are going back to working with repunits in a problem that readsFind the sum of the first forty prime factors of the repuint R(109).This is a pretty large number, and having to actually do trial division would be a pain and take quite a while, even though we have BigInteger class which is certainly a help here.

Continue reading...Saturday, January 12, 2013

I am pretty sure the Problem 131 of Project Euler can be brute forced. However, if you start digging you will see that there is a really beautiful solution to the problem that readsThere are some prime values, p, for which there exists a positive integer, n, such that the expression n3 + n2p is a perfect cube.How many primes below one million have this remarkable property?

Continue reading...Saturday, December 22, 2012

Problem 128 is a really interesting problem about prime numbers. It readsA hexagonal tile with number 1 is surrounded by a ring of six hexagonal tiles, starting at "12 o'clock" and numbering the tiles 2 to 7 in an anti-clockwise direction. New rings are added in the same fashion, with the next rings being numbered 8 to 19, 20 to 37, 38 to 61, and so on. By finding the difference between tile n and each its six neighbours we shall define PD(n) to be the number of those differences which are prime. It can be shown that the maximum value of PD(n) is 3. Find the 2000th with PD(n) = 3.My initial thought was that it will kill me if I have to go through every number and check if they fulfill the criteria, so I started looking for patterns such that I could eliminate some numbers that I did not have to check.

Continue reading...Saturday, November 17, 2012

Problem 123 of Project Euler readsLet pn be the nth prime: 2, 3, 5, 7, 11, ..., and let r be the remainder when (pn-1)n + (pn+1)n is divided by pn2.Find the least value of n for which the remainder first exceeds 1010.A nice and short problem description which will also have a nice and short solution post since we solved Problem 120 which is very similar to this problem.

Continue reading...Sunday, October 7, 2012

Here is some news of the possible breakthrough of the ABC conjecture. It might already be commonly known, but it is something I only recently discovered was going on. There are rumors that Shinichi Mochizuki from Kyoto university has solved the abc conjecture. You can find his proof here. Not that I understood anything of it, but I though a […]

Continue reading...Thursday, September 6, 2012

I got a fun little question from Jean-Marie by email the other day. With the disclaimer that I don’t really have the time to solve that many puzzles and therefore probably wont be able to give you a solution to puzzles like this one. This one triggered my curiosity and I managed to find a […]

Continue reading...Saturday, August 25, 2012

So in Problem 111 of Project Euler we are back at dealing with prime numbers. And rather large ones of them. But before going into details, here is the problem descriptionWe shall say that M(n, d) represents the maximum number of repeated digits for an n-digit prime where d is the repeated digit, N(n, d) represents the number of such primes, and S(n, d) represents the sum of these primes.Find the sum of all S(10, d).I rather quickly realized that there must be two solution approaches to this problem. Either we generate all the primes in the range and start finding the right ones. Or we can generate numbers with repeated digits and check if they are primes.I started out with the first approach, by trying to generate primes up to 10.000.000.000, but I ran into problems with my sieve as we have to index more than can be stored in an integer. So either I could rewrite the sieve or I could look into the other approach.

Continue reading...This site uses cookies.

Saturday, April 27, 2013

4 Comments