Let us denote by [x] the greatest integer ≤ x.
How many positive integers p satisfy [p/95]=[p/97]?
How many positive integers q satisfy [q/2005]=[q/2007]?
1<=p<=94 satisfy the first equation
97<=p<=189 satisfy the first equation
194<=p<=234 satisfy the first equation
...
Line 1 above has 94 members.
Line 2 has 93.
Line 3 has 91, and from here down, each line has 2 fewer members, as the beginning increases by 97 and the end increases by 95. The first line is outside this pattern as zero was not counted as eligible to be p.
So the total is the sum of the odd numbers from 1 through 93 plus 94. That amounts to 47*47 + 94 = 2303 numbers satisfying the first equation. This is verified by the program
first = 97: last = 189
DO WHILE last >= first
t = t + last  first + 1
first = first + 97: last = last + 95
LOOP
t = t + 94
PRINT t
For the second equation:
1<=q<=2004 satisfy the second equation.
2007<=q<=4009 satisfy the second equation.
2014<=q<=6004 satisfy the second equation.
...
Line 1 has 2004 members.
Line 2 has 2003 members.
Line 3 has 2001 members.
...
The total is the sum of the odd numbers from 1 through 2003 plus 2004. That's 1002*1002+2004 = 1,006,008 different values of q, verified by
DEFDBL AZ
first = 2007: last = 4009
DO WHILE last >= first
t = t + last  first + 1
first = first + 2007: last = last + 2005
LOOP
t = t + 2004
PRINT t

Posted by Charlie
on 20061128 10:37:49 