Let n be a three-digit positive integer such that the last three digits of n2 are the same as those of n. This means n2≡n(mod1000).
So, n2−n≡0(mod1000), or n(n−1)≡0(mod1000).
Since n and n−1 are consecutive integers, they are coprime. Therefore, 1000=23⋅53 must divide either n or n−1.
Case 1: n≡0(mod1000)
But n is a three-digit integer, so 100≤n≤999, so n=1000 is not possible.
Case 2: n−1≡0(mod1000)
Then n=1001, which is not a three-digit integer.
So we need to consider the factors of 1000 split between n and n−1.
Let n be divisible by a and n−1 by b, where a⋅b=1000 and gcd(a,b)=1.
All pairs (a,b) where a and b are coprime and a⋅b=1000:
The divisors of 1000 are 1,2,4,5,8,10,20,25,40,50,100,125,200,250,500,1000.
We list all pairs (a,b) such that a⋅b=1000 and gcd(a,b)=1:
- (1,1000)
- (8,125)
- (125,8)
- (5,200)
- (200,5)
- (25,40)
- (40,25)
Now, for each pair, n is divisible by a, n−1 by b.
So n≡0(moda) and n≡1(modb).
By the Chinese Remainder Theorem, since a and b are coprime, there is a unique solution modulo 1000 for each pair.
Let us compute n for each pair and check if n is a three-digit integer.
1. (a,b)=(8,125)
n≡0(mod8)
n≡1(mod125)
Let n=8k, so 8k≡1(mod125)
Find k such that 8k≡1(mod125)
The inverse of 8 modulo 125 is 47, since 8×47=376=1+3×125=1(mod125)
So k≡47(mod125)
So n=8k=8×47=376
Check if n is three-digit: 376 is three-digit.
Also, k can be 47+125m, so n=8×(47+125m)=376+1000m
But n must be three-digit, so only m=0 works.
So n=376.
2. (a,b)=(125,8)
n≡0(mod125)
n≡1(mod8)
Let n=125k, so 125k≡1(mod8)
125≡5(mod8), so 5k≡1(mod8)
The inverse of 5 modulo 8 is 5, since 5×5=25≡1(mod8)
So k≡5(mod8)
So n=125×5=625
Again, n=625 is three-digit.
3. (a,b)=(5,200)
n≡0(mod5)
n≡1(mod200)
Let n=5k, so 5k≡1(mod200)
The inverse of 5 modulo 200 is 41, since 5×41=205=1+1×200=5(mod200)
Wait, 5×41=205≡5(mod200), not 1.
Try 5k≡1(mod200)
Try k=1, 5×1=5; 5×41=205; 205−200=5.
Try k=41, 5×41=205≡5(mod200)
Try k=81, 5×81=405≡5(mod200)
Try k=161, 5×161=805≡5(mod200)
So 5k always ends with 5 modulo 200.
But 5k≡1(mod200), so 5k=1+200m, k=(1+200m)/5, but 1+200m must be divisible by 5.
1+200m≡0(mod5)
200m≡−1(mod5)
200≡0(mod5), so 0≡−1(mod5), which is impossible.
So no solution for this pair.
4. (a,b)=(200,5)
n≡0(mod200)
n≡1(mod5)
Let n=200k, 200k≡1(mod5)
200≡0(mod5), so 0×k≡1(mod5), which is impossible.
So no solution for this pair.
5. (a,b)=(25,40)
n≡0(mod25)
n≡1(mod40)
Let n=25k, 25k≡1(mod40)
25≡25(mod40), so 25k≡1(mod40)
Find inverse of 25 modulo 40.
Try 25×9=225≡25(mod40)
Try 25×9=225, 225−5×40=225−200=25
Try 25×33=825, 825−20×40=825−800=25
Try 25×33=825≡25(mod40)
Try 25×33=825, 825−20×40=825−800=25
Try k=1, 25×1=25
Try k=25, 25×25=625, 625−15×40=625−600=25
Try k=17, 25×17=425, 425−10×40=425−400=25
So 25k always ends with 25 modulo 40.
So 25k≡1(mod40), 25k=1+40m, k=(1+40m)/25, 1+40m≡0(mod25)
40m≡−1(mod25)
40≡15(mod25), so 15m≡−1(mod25)
Find m such that 15m≡24(mod25)
Try m=24, 15×24=360, 360≡10(mod25)
Try m=16, 15×16=240, 240≡15(mod25)
Try m=9, 15×9=135, 135≡10(mod25)
Try m=19, 15×19=285, 285≡10(mod25)
Try m=14, 15×14=210, 210≡10(mod25)
Try m=21, 15×21=315, 315≡15(mod25)
Try m=23, 15×23=345, 345≡20(mod25)
Try m=24, 15×24=360, 360≡10(mod25)
Try m=1, 15×1=15, 15≡15(mod25)
Try m=2, 15×2=30, 30≡5(mod25)
Try m=3, 15×3=45, 45≡20(mod25)
Try m=4, 15×4=60, 60≡10(mod25)
Try m=5, 15×5=75, 75≡0(mod25)
So m=5, 15×5=75≡0(mod25), so 15m≡0(mod25)
But we want 15m≡24(mod25)
Try m=24, 15×24=360≡10(mod25)
Try m=9, 15×9=135≡10(mod25)
Try m=11, 15×11=165≡15(mod25)
Try m=16, 15×16=240≡15(mod25)
Try m=23, 15×23=345≡20(mod25)
Try m=24, 15×24=360≡10(mod25)
Try m=17, 15×17=255≡5(mod25)
Try m=8, 15×8=120≡20(mod25)
Try m=19, 15×19=285≡10(mod25)
Try m=21, 15×21=315≡15(mod25)
Try m=22, 15×22=330≡5(mod25)
Try m=13, 15×13=195≡20(mod25)
Try m=18, 15×18=270≡20(mod25)
Try m=6, 15×6=90≡15(mod25)
Try m=7, 15×7=105≡5(mod25)
Try m=12, 15×12=180≡5(mod25)
Try m=20, 15×20=300≡0(mod25)
Try m=25, 15×25=375≡0(mod25)
So, perhaps this is not working. Let's try another approach.
Alternatively, since 25k≡1(mod40), 25k=1+40m, k=(1+40m)/25, 1+40m must be divisible by 25.
1+40m≡0(mod25)
40m≡−1(mod25)
40≡15(mod25), so 15m≡24(mod25)
Now, 15m≡24(mod25)
The inverse of 15 modulo 25 is 5, since 15×5=75≡0(mod25), so 15×2=30≡5(mod25), 15×7=105≡5(mod25)
Try m=24, 15×24=360≡10(mod25)
Try m=19, 15×19=285≡10(mod25)
Try m=9, 15×9=135≡10(mod25)
Try m=16, 15×16=240≡15(mod25)
Try m=21, 15×21=315≡15(mod25)
Try m=23, 15×23=345≡20(mod25)
Try m=8, 15×8=120≡20(mod25)
Try m=13, 15×13=195≡20(mod25)
Try m=22, 15×22=330≡5(mod25)
Try m=12, 15×12=180≡5(mod25)
Try m=17, 15×17=255≡5(mod25)
Try m=14, 15×14=210≡10(mod25)
Try m=11, 15×11=165≡15(mod25)
Try m=6, 15×6=90≡15(mod25)
Try m=4, 15×4=60≡10(mod25)
Try m=3, 15×3=45≡20(mod25)
Try m=2, 15×2=30≡5(mod25)
Try m=1, 15×1=15≡15(mod25)
Try m=0, 15×0=0≡0(mod25)
So, perhaps there is no solution for this pair.
6. (a,b)=(40,25)
n≡0(mod40)
n≡1(mod25)
Let n=40k, 40k≡1(mod25)
40≡15(mod25), so 15k≡1(mod25)
The inverse of 15 modulo 25 is 12, since 15×12=180=7×25+5=5(mod25)
Wait, 15×12=180, 180−7×25=180−175=5
Try k=2, 15×2=30≡5(mod25)
Try k=7, 15×7=105≡5(mod25)
Try k=17, 15×17=255≡5(mod25)
Try k=23, 15×23=345≡20(mod25)
Try k=24, 15×24=360≡10(mod25)
Try k=9, 15×9=135≡10(mod25)
Try k=11, 15×11=165≡15(mod25)
Try k=1, 15×1=15≡15(mod25)
Try k=3, 15×3=45≡20(mod25)
Try k=8, 15×8=120≡20(mod25)
Try k=13, 15×13=195≡20(mod25)
Try k=18, 15×18=270≡20(mod25)
Try k=19, 15×19=285≡10(mod25)
Try k=14, 15×14=210≡10(mod25)
Try k=16, 15×16=240≡15(mod25)
Try k=21, 15×21=315≡15(mod25)
Try k=22, 15×22=330≡5(mod25)
Try k=12, 15×12=180≡5(mod25)
Try k=5, 15×5=75≡0(mod25)
Try k=10, 15×10=150≡0(mod25)
Try k=15, 15×15=225≡0(mod25)
Try k=20, 15×20=300≡0(mod25)
So, perhaps there is no solution for this pair.
Therefore, the only three-digit solutions are n=376 and n=625.
Check:
3762=141376, last three digits are 376.
6252=390625, last three digits are 625.
Thus, the answer is 376 and 625.