Is there a formula for the number of perfect squares that are less than a given integer a inclusive, I'm sure it uses the integer part function but playing around I can't seem to establish one. The number of perfect squares less than a is $\lfloor{\sqrt{a}}\rfloor$ but I don't think that the number of odd perfect squares is just half of this.
Number of odd perfect squares,n, in the interval 1-a inclusive
229 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 3 best solutions below
On
You can put Lulu's comment into a single expression: $\left\lfloor\frac{1+\sqrt{a}}{2}\right\rfloor$
On
Let $N$ be the number of odd integers squared in the interval $[1, a]$.
Let $A=\lfloor {\sqrt a} \rfloor$ Then $A$ is an integer and $A \le \sqrt a < A+1$ implies that $A^2 \le a < (A+1)^2$.
So $\lfloor {\sqrt a} \rfloor$ is the number of perfect squares less than or equal to $a$.
An odd integer squared is an odd integer and an even integer squared is an even integer. So N will be equal to the number of odd integers in the interval $[1, \lfloor {\sqrt a} \rfloor]$.
If $\lfloor {\sqrt a} \rfloor$ is an even integer, then there are as many odd integers from $1$ to $\lfloor {\sqrt a} \rfloor$ as there are even integers and $N = \frac 12 \lfloor {\sqrt a} \rfloor$
If $\lfloor {\sqrt a} \rfloor$ is an odd integer, then there are as many odd integers in the interval $[1, \lfloor {\sqrt a} \rfloor]$ as there are even integers in the interval $[1, \lfloor {\sqrt a} \rfloor + 1]$. So $N = \frac 12(\lfloor {\sqrt a} \rfloor + 1)$
So $N = \begin{cases} \frac 12 \lfloor {\sqrt a} \rfloor & \text{If $\lfloor {\sqrt a} \rfloor$ is even} \\ \frac 12 (\lfloor {\sqrt a} \rfloor + 1) & \text{If $\lfloor {\sqrt a} \rfloor$ is odd} \end{cases}$
We can simplify this.
If $\lfloor {\sqrt a} \rfloor$ is even, then $\frac 12 \lfloor {\sqrt a} \rfloor$ is an integer and $N = \frac 12 \lfloor {\sqrt a} \rfloor$
If $\lfloor {\sqrt a} \rfloor$ is odd, then $\frac 12 \lfloor {\sqrt a} \rfloor$ is not an integer and $N = \frac 12 \lfloor {\sqrt a} \rfloor + \frac 12$.
This implies that $N = \left \lceil \frac 12 \lfloor {\sqrt a} \rfloor\right \rceil$
The formula is $\left \lceil \frac{\left \lfloor \sqrt{a} \right \rfloor}{2} \right \rceil$.
Using the $\left \lfloor \sqrt{a} \right \rfloor$ formula for counting the number of perfect squares less than $n$, we could tweak it to count only those odd numbers by dividing by 2, then applying the ceiling function.