Problem:
For each positive integer p, let b(p) denote the unique positive integer k such that β£kβpββ£<21β. For example, b(6)=2 and b(23)=5. If S=βp=12007βb(p), find the remainder when S is divided by 1000.
Solution:
First, if k is a nonnegative integer, and n is a positive integer then n2+kβ<n+21ββΊn2+k<n2+n+41ββΊk<n+41ββΊk=0,1,2,β¦,n. Similarly, nβ21β<n2βkββΊn2βn+41β<n2βkβΊk<nβ41β. So if k is a positive integer, the second inequality is satisfied when k=1,2,3,β¦,nβ1. Thus a positive integer n is the value of b(p) precisely when p is one of the (n+1)+(nβ1)=2n integers n2β(nβ1),n2β(nβ2),β¦,n2β1,n2,n2+1, ..., n2+n.
Next, observe that 442=1936<1936+44=1980<2007<452=2025. Therefore each integer n=1,2,3,β¦,44 contributes nβ 2n=2n2 to the sum. Consequently,