# Number of odd perfect squares,n, in the interval 1-a inclusive [closed]

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.

## closed as off-topic by Namaste, José Carlos Santos, Shailesh, J. M. is a poor mathematician, Xander HendersonSep 4 '17 at 2:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Namaste, José Carlos Santos, Shailesh, J. M. is a poor mathematician, Xander Henderson
If this question can be reworded to fit the rules in the help center, please edit the question.

• it would depend on if the previous square is odd or even. – user451844 Sep 3 '17 at 13:42
• Could you elaborate – William Manley Sep 3 '17 at 13:43
• If $\lfloor \sqrt a \rfloor$ is odd, call it $2k+1$, then there are $k+1$ . If it is even, call it $2k$ then there are $k$ – lulu Sep 3 '17 at 13:45

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.

You can put Lulu's comment into a single expression: $\left\lfloor\frac{1+\sqrt{a}}{2}\right\rfloor$

• Can you explain the intuition behind this please? – William Manley Sep 3 '17 at 13:57

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$