Twin Primes
Twin primes are two primes that differ by exactly 2, like 11 and 13. Return how many twin prime pairs (p, p + 2) exist with both numbers at most n.
Example 1
n 20
returns 4
(3,5), (5,7), (11,13), (17,19).
Constraints
1 <= n <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.