Mickeys
asked on
Evenly divisible
ASKER
So to get the correct answer. Would I use this
(123^121+121^123) mod 122= ((122+1)^121) mod 122+ ((122-1)^123)mod 122= (1^121) mod 122 +((-1)^123) mod 122 = 1 mod 122+ (-1) mod 122= (1-1) mod 122 =0
or this?
(n+1)^(n-1) % n = [ (n+1) % n ] ^ (n-1) = [ n % n +1 % n ] ^ (n-1) = [ 0 + 1 ] ^ (n-1) = 1
(n-1)^(n+1) % n = [ (n-1) % n ] ^ (n+1) = [ n % n - 1 % n ] ^ (n+1) = [ 0 - 1 ] ^ (n+1) = -1
(123^121+121^123) mod 122= ((122+1)^121) mod 122+ ((122-1)^123)mod 122= (1^121) mod 122 +((-1)^123) mod 122 = 1 mod 122+ (-1) mod 122= (1-1) mod 122 =0
or this?
(n+1)^(n-1) % n = [ (n+1) % n ] ^ (n-1) = [ n % n +1 % n ] ^ (n-1) = [ 0 + 1 ] ^ (n-1) = 1
(n-1)^(n+1) % n = [ (n-1) % n ] ^ (n+1) = [ n % n - 1 % n ] ^ (n+1) = [ 0 - 1 ] ^ (n+1) = -1
I prefer symbols, but you can choose the approach you feel more comfortable with.
Let n = 122, then
(n+1)^(n-1) % n = (122+1)^(122-1) % 122 = (123^121) mod 122
and
(n-1)^(n+1) % n = (122-1)^(122+1) % 122 = (121^123) mod 122
Can you make the final conclusions from this substitution by comparing it with your OP?
Let n = 122, then
(n+1)^(n-1) % n = (122+1)^(122-1) % 122 = (123^121) mod 122
and
(n-1)^(n+1) % n = (122-1)^(122+1) % 122 = (121^123) mod 122
Can you make the final conclusions from this substitution by comparing it with your OP?
ASKER
no :-(
>> no :-(
Could you elaborate?
For example, what part of the substitution are you having trouble with?
Could you elaborate?
For example, what part of the substitution are you having trouble with?
ASKER
well all I really wanted to know was if my solution was correct
Yes.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
These are your steps with the justifications. Looks complete to me.
Oh, that first step also used (a+b) % n = a%n + b%n
a^k % n = (a%n)^k
(a+b) % n = a%n + b%n
(n+1)^(n-1) % n = [ (n+1) % n ] ^ (n-1) = [ n % n +1 % n ] ^ (n-1) = [ 0 + 1 ] ^ (n-1) = 1
(n-1)^(n+1) % n = [ (n-1) % n ] ^ (n+1) = [ n % n - 1 % n ] ^ (n+1) = [ 0 - 1 ] ^ (n+1) = -1