Finding a solution for quadratic inequality

135 Views Asked by At

Given $r$ and $t$, Is there a way to find the maximum positive integer $N$ such that:

$$2 N^2 + (2r+3)N + (2r+1) \leq t$$

I want to write a program to solve that inequality without brute-force. At least the program should be as fast as possible.

1

There are 1 best solutions below

3
On BEST ANSWER

Use the quadratic formula and floor the result(s):

In standard form: $0 = ax^2 + bx + c$

$a = 2$

$b = (2r + 3)$

$c = (2r + 1 - t)$