# Find near miss prime multiples.

Given a number $n \geq 3$ as input output the smallest number $k$ such that the modular residues of $k$ by the first $n$ primes is exactly $\{-1,0,1\}$.

That is there is a prime in the first $n$ primes that divides $k$, one that divides $k+1$ and one that divides $k-1$, *and* every prime in the first $n$ primes divides one of those three values.

For example if $n=5$, the first $5$ primes are $2, 3, 5, 7, 11$ the value must be at least $10$ since with anything smaller $11$ is an issue. So we start with $10$:

$$ 10 \equiv 0 \mod 2 $$$$ 10 \equiv 1 \mod 3 $$$$ 10 \equiv 0 \mod 5 $$$$ 10 \equiv 3 \mod 7 $$Since $10 \mod 7 \equiv 3$, $10$ is not a solution so we try the next number.

- $11 \equiv 4\mod 7$ so we try the next number.
- $12 \equiv 2\mod 5$, so we try the next number.
- $13 \equiv 3\mod 5$, so we try the next number.
- $14 \equiv 3\mod 11$, so we try the next number.
- $15 \equiv 4\mod 11$, so we try the next number.
- $16 \equiv 2\mod 7$, so we try the next number.
- $17 \equiv 2\mod 5$, so we try the next number.
- $18 \equiv 3\mod 5$, so we try the next number.
- $19 \equiv 5\mod 7$, so we try the next number.
- $20 \equiv 9\mod 11$, so we try the next number.

21 satisfies the property so its the answer.

## Task

Take as input $n \geq 3$ and give as output the smallest number satisfying.

This is code-golf. The goal is to minimize the size of your source code as measured in bytes

## Test cases

```
3 -> 4
4 -> 6
5 -> 21
6 -> 155
7 -> 441
```

## 2 comment threads