Project Euler 196 - Prime Triplets

Official link: https://projecteuler.net/problem=196

Thought Process

Not too difficult problem. The idea to find S(n) is simple

Now all we need to do is generate the 5 rows we care about (That is 2 rows below and above the row we care about) and find which elements are prime.

Finding the rows is trivial, and to find the primes I implemented a prime_sieve_in_range function, which I'm honestly very surprised I hadn't done yet! It is based on the Sieve of Eratosthenes.

Interactive Code

Input an integer (yourinput)

Code will output S(yourinput)