For which $n$ does $\sqrt{n }< n/2$ hold?

70 Views Asked by At

When testing with some positive values except for $1$, it seems that $\sqrt{n} \leq n/2$. However I did not see that property anywhere. Is it true ? Would it be possible to prove it ?

Thanks.

Ps: it is for computing the integer square root of a number. You can use binary search between $[0,\ldots, n]$ (and reducing the set of candidate to a 1 entry array). But if $n > 1$ AND if this property holds, you could use it between $[0,\ldots, n/2]$ which could lead to higher performance !

2

There are 2 best solutions below

4
On BEST ANSWER

Multiply by two, and square (which is alright in this case) to get the equivalent

$$4n \le n^2$$

Now cancel $n$ (which is also alright in this case) to get $4\le n$.

The inequality (in the body) is true if and only if $n \ge 4$, the one in the title if this inequality is strict.

0
On

For $n>0$, $$\sqrt n<\frac n2\iff n<\frac{n^2}4\iff n(n-4)>0\iff n>4$$