Problem Description
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are permutations of one another.
There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes, exhibiting this property, but there is one other 4-digit increasing sequence.
What 12-digit number do you form by concatenating the three terms in this sequence?
Analysis
An obvious solution. Start with the known solution plus 2 (1487+2) and find the next set checking only odd numbers.
Solution
Runs < 1 second in Python.
from Euler import is_prime, is_perm n = 1489 # must be odd while True: b, c = n+3330, n+6660 if is_prime(n) and is_prime(b) and is_prime(c) \ and is_perm(n,b) and is_perm(b,c): break n += 2 print "Answer to PE49 = ", str(n)+str(b)+str(c)
Comments
- More information on the Euler module can be found on the tools page.
- It wasn’t clear, perhaps intentionally, that the terms in the sequence would increase by the same amount (3330) as the example.





Discussion
No comments for “Project Euler Problem 49 Solution”