Need expert helpâ€”fast? Use the Help Bell for personalized assistance getting answers to your important questions.

aa % n = (a % n) (a % n)

a^k % n = (a%n)^k

(a+b) % n = a%n + b%n

More generally, you could write: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

(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

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?

Could you elaborate?

For example, what part of the substitution are you having trouble with?

All Courses

From novice to tech pro — start learning today.

= ((122+1)^121) mod 122+ ((122-1)^123)mod 122 ----- simple arithmetic

= (1^121) mod 122 +((-1)^123) mod 122 ----- a^k % n = (a%n)^k

= 1 mod 122+ (-1) mod 122 ------ simple algebra

= (1-1) mod 122 --------- (a+b) % n = a%n + b%n

=0 --------- simple arithmetic and 0 mod a = 0 (where a not= 0)