Quantcast
Channel: korp - Python
Viewing all articles
Browse latest Browse all 4

Google Treasure Hunt: Last problem

$
0
0

The last and fourth problem from Google Treasure Hunt deals with consecutive prime numbers. Its basic form is:

Find the smallest number that can be expressed as
the sum of m consecutive prime numbers,
the sum of n consecutive prime numbers,
the sum of o consecutive prime numbers,
the sum of p consecutive prime numbers,
and is itself a prime number.

For example, 41 is the smallest prime number that can be expressed as
the sum of 3 consecutive primes (11 + 13 + 17 = 41) and
the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).

In the case of m, n, o, and p, there are four conditions, although there can be more. The example of 41 has only two conditions, for instance.

Again, my solution was written in Python and is designed to scale to a variable amount of conditions, as seen in the primes.py I wrote:

read more


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images