Prime numbers larger than 5 can end only in 1, 3, 7, or 9, but of course not all numbers ending in these four digits are prime. Let’s call a group of four prime numbers between
and
(with k an integer and
) a prime quartet. The first one is 11, 13, 17, and 19, and the second is 101, 103, 107, and 109. Therefore, the prefix (or the number excluding the last digit) of the first prime quartet is 1, and the prefix of the second prime quartet is 10.
Write a function that returns the nth prime quartet prefix.
Optional: Prove that the sequence of prime quartet prefixes is infinite. Just drop your proof in the comments below.
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers9
Suggested Problems
-
19183 Solvers
-
Project Euler: Problem 1, Multiples of 3 and 5
3665 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
2035 Solvers
-
How long do each of the stages of the rocket take to burn?
452 Solvers
-
240 Solvers
More from this Author321
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Nice problem , made me think :)
Ah! this was a cool opportunity to use a regex in a fair way:
with 'n' input
persistent a
if isempty(a)
primes(27e7);
a=regexp(sprintf('%d.',ans),'(\d+)1\.\13\.\17\.\19\.','match');
end
strsplit(a{n},'.'); str2num(ans{1}(1:end-1))