Translating Code into Math?

545 Views Asked by At

This is my first posting here, so I am not sure this is in the correct place.

I have this math problem: Find the number of distinct integers in this set:

$$\left\{\left[\frac{1^2}{5012}\right], \left[\frac{2^2}{5012}\right],\ldots, \left[ \frac{5012^2}{5012}\right]\right\},$$

where $[x]$ denotes the greatest integer less than or equal to $x$.

I am not very familiar with the mathematical notation involved with this problem, so I wrote a computer program that solves it (in Java)

I get the correct answer: 3760, and I get the entire set of distinct integers. But I do not know how to represent this mathematically. Any help is appreciated! Thank you.

1

There are 1 best solutions below

0
On

There are two regimes here. We know the gap between squares grows as the square root grows larger. As long as the gap between $k^2$ and $(k+1)^2$ is less than $5012$ we will hit every integer because the gaps between the fractions is less than $1$. When the gap is larger than $5012$, the integers will all be distinct. As the gap between $k^2$ and $(k+1)^2$ is $2k+1$, it becomes larger than $5012$ at $k=2506$. So in the set we have every integer from $0$ through $\frac {2506^2}{5012}=1253$, or $1254$ of them, and then all the ones from $\lfloor \frac {2507^2}{5012}\rfloor$ through $\lfloor \frac {5012^2}{5012}\rfloor$, or $2506$ of them, a total of $3760$.