n n ≡ n ( m o d 1 0 0 )
How many positive integers n less than 100 satisfy the above congruence?
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.
It depends, eh. (Some youngster caught me making an assertion like this a few months ago.) Here is a pair of Python codes and their timings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Output:
1 2 3 4 5 6 |
|
Did exactly the same (+1)!
I used Python to do this question. Code below:
Note:
Using
pow(a,d,n)
is
faster than
using
(a**d)%n
and both give the same result.
When you don't need to explicitly evaluate the exponentiated value but just need to do modular exponentiation, use the
pow()
function with 3 parameters.
Similar here. But I use x instead of x%100, because x is less than 100.
Python one-liner:
1 2 |
|
the same...but level 4 is to much for this
I used C++ to solve.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
The output is 21 .
1 2 3 4 |
|
quicky. Implemented pow(x,y,z) thanks to @Prasun Biswas who commented it was faster.
For numbers ending in 1 we can have n=1,11,21,.....91 ie all 10.
For 3 we have only 93.
For 5 we have 25 and 75.
For 6 we have 16,36,56,76,96.
For 7 we have only 57.
For 9 we have 49,99.
No solutions for 2,4,8.
So we have 23 numbers in all
How did you arrive at these numbers?
Log in to reply
The proof is a bit long. I basically proved that n^n-n in these cases is divisible by 100.
Log in to reply
Post that, that is what is required as a solution, not just the answer.
Problem Loading...
Note Loading...
Set Loading...
There is no need to calculate big numbers like n n . After each multiplication we can reduce the product modulo 100. This will keep everything well within usual integer range (and faster!)
Output: