What is the sum of all six-digit positive integer(s) such that they satisfy the property that the number equals to the last six (rightmost) digits of its own square?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Great solution!
This is brilliant - I totally forgot about factoring and derived a non-linear recursive relation for the digits, starting with the least significant digit d 0 on the right. Using m o d 1 0 on both sides, you get d 0 2 ≡ d 0 m o d 1 0 ⇒ d 0 ∈ { 0 ; 1 ; 5 ; 6 } and can work from there to find the recursive relation, it will involve a convolution of the digits already found. The first two cases lead to x = 0 , x = 1 and can be ignored for 6-digit solutions. You conveniently ignored them too, I see...
Log in to reply
Well, I consider 0 and 1 to be 1-digit integers....
Log in to reply
They are, but they are also solutions to x ( x − 1 ) ≡ 0 m o d 1 0 6 . I know it's nitpicking (and I'm sorry if I'm being too pedantic here), but wouldn't it be clearer to list them, too, and discard them later for not having enough digits?
Log in to reply
@Carsten Meyer – Oh, I immediately make the constraint that x is a 6-digit number, so I didn't bother writing x = 0 , 1 should be a solution. I'm going to add that in.
total <- 0
for(k in 10^5:(10^6-1)){
if(k == (k^2 %% 10^6)){
total <- total + k
}
}
print(total)
Problem Loading...
Note Loading...
Set Loading...
Let 1 0 5 ⩽ x < 1 0 6 be the integer(s) satisfying the given constraints.
We have x 2 ≡ x ( m o d 1 0 6 ) ⇒ x ( x − 1 ) ≡ 0 ( m o d 1 0 6 ) . Because x and x − 1 are coprime and 1 0 6 factors to 2 6 × 5 6 , then one of x , x − 1 divides 2 6 and the other divides 5 6 . This will be a simple case of Chinese Remainder Theorem.
Case 1: x m o d 2 6 = 0 , x m o d 5 6 = 1 ⇒ x = 1 0 9 3 7 6
Case 2: x m o d 2 6 = 1 , x m o d 5 6 = 0 ⇒ x = 8 9 0 6 2 5
Add them up gives 1 0 6 + 1 .