# 2007 iTest Problems/Problem 57

The following problem is from the Ultimate Question of the 2007 iTest, where solving this problem required the answer of a previous problem. When the problem is rewritten, the T-value is substituted.

## Problem

How many positive integers are within $810$ of exactly $\lfloor \sqrt{810} \rfloor$ perfect squares? (Note: $0^2=0$ is considered a perfect square.)

## Solution

This problem is essentially asking for how many $n$ are there $28$ perfect squares from $n-810$ to $n+810$.

To find the bounds, note that the difference between consecutive perfect squares are odd numbers. As it increases, the distance between perfect squares increase. Let $a$ be the difference between the minimum perfect square and the next perfect square. Since there are $28$ perfect squares in the range, the last difference is $a+54$, and the sum of the differences is $\tfrac{1}{2} \cdot 28(2a+54)$. This equals $1620$, so writing an equation and solving for $a$ yields $a \approx 30$. The sum of the odd numbers from $1$ to $29$ is $225$, so we found a place to start.

Using the boundries as reference, we can make a table to find values of $n$ and find the number of perfect squares.

 Value of $n$ Value of $n-810$ Value of $n+810$ Smallest PS in bound Largest PS in bound Number of PS $980$ $170$ $1790$ $14^2 = 196$ $42^2 = 1764$ $29$ $1007$ $197$ $1817$ $15^2 = 225$ $42^2 = 1764$ $28$ $1035$ $225$ $1845$ $15^2 = 225$ $42^2 = 1764$ $28$ $1036$ $226$ $1846$ $16^2 = 256$ $42^2 = 1764$ $27$ $1039$ $229$ $1849$ $16^2 = 256$ $43^2 = 1849$ $28$ $1066$ $256$ $1876$ $16^2 = 256$ $43^2 = 1849$ $28$

If $n$ gets below $1007$, then there will be more perfect squares because $12^2 = 144$ while $41^2 = 1681$, so more perfect squares would be gained than lost. Similarly, if $n$ gets above $1066$, then there will be less perfect squares because $18^2 = 324$ while $44^2 = 1936$, so more perfect squares would be lost than gained.

Based on the table, there are $(1035-1007+1)+(1066-1039+1) = \boxed{57}$ integers that satisfy the criteria.