- All Contests
- ProjectEuler+
- Project Euler #58: Spiral primes

# Project Euler #58: Spiral primes

# Project Euler #58: Spiral primes

_{This problem is a programming version of Problem 58 from projecteuler.net}

Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed.

It is interesting to note that the odd squares lie along the bottom right diagonal, but what is more interesting is that 8 out of the 13 numbers lying along both diagonals are prime; that is, a ratio of .

If one complete new layer is wrapped around the spiral above, a square spiral with side length 9 will be formed. If this process is continued, what is the side length of the square spiral for which the ratio of primes along both diagonals first falls below ?

**Input Format**

Input contains an integer

**Constraints**

**Output Format**

Print the answer corresponding to the test case.

**Sample Input**

```
60
```

**Sample Output**

```
5
```