We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

- All Contests
- ProjectEuler+
- Project Euler #66: Diophantine equation

# Project Euler #66: Diophantine equation

# Project Euler #66: Diophantine equation

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

Consider quadratic Diophantine equations of the form:

For example, when , the minimal solution in is . It can be assumed that there are no solutions in positive integers when D is square.

By finding minimal solutions in for , we obtain the following:

Hence, by considering minimal solutions in for , the largest is obtained when .

Find the value of in minimal solutions of for which the largest value of is obtained.

**Input Format**

Input contains an integer .

**Constraints**

**Output Format**

Print the answer corresponding to the test case.

**Sample Input**

```
7
```

**Sample Output**

```
5
```

**Explanation**

Explained in statement.