Counting how many integers give a integer in the square root

46 Views Asked by At

My question is about a Mathematica code that gives the same as a mathematical experssion (for integers) but I do not know why.

The mathematica code is the following (you can try it out for integers on wolframalpha):

Count[Table[FractionalPart[Sqrt[n]],{n,#}],0]&/@{k}

And it gives the same as:

$$\lfloor\sqrt{k}\rfloor\tag1$$

Why is that true?

1

There are 1 best solutions below

0
On BEST ANSWER

I am not super familiar with Mathematica, but it seems that your code asks how many elements between $1$ and $k$ have fractional part zero when taking the square root.

i.e. How many elements are a square between $1$ and $k$. You could also ask the question of how many elements have squares that are less than $k$.

This latter question can be answered by noting that you need only find the largest integer less than $\sqrt{k}.$

i.e. $\lfloor{\sqrt{k}}\rfloor.$