Solved

# Evenly divisible

Posted on 2010-11-30
327 Views

(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
0
Question by:Mickeys
• 4
• 4
• 3

LVL 32

Expert Comment

ID: 34242672
Where % ~ mod, it looks like you are using these principles:
aa % n = (a % n) (a % n)
a^k % n = (a%n)^k
(a+b) % n = a%n + b%n
More generally, you could write:
(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
0

Author Comment

ID: 34242725
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

0

LVL 32

Expert Comment

ID: 34242841
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?
0

Author Comment

ID: 34242929
no :-(
0

LVL 32

Expert Comment

ID: 34242945
>> no :-(
Could you elaborate?
For example, what part of the substitution are you having trouble with?
0

Author Comment

ID: 34243036
well all I really wanted to know was if my solution was correct
0

LVL 37

Expert Comment

ID: 34243258
Yes.
0

LVL 32

Assisted Solution

phoffric earned 250 total points
ID: 34243284
Ok, let me check by using n=122 for your solution...

I checked it, and your solution is correct. However, I recommend adding extra steps.

0

LVL 37

Accepted Solution

TommySzalapski earned 250 total points
ID: 34243292
(123^121+121^123) mod 122
= ((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)
0

LVL 37

Expert Comment

ID: 34243301
These are your steps with the justifications. Looks complete to me.
0

LVL 37

Expert Comment

ID: 34243324
Oh, that first step also used (a+b) % n = a%n + b%n
0

## Featured Post

### Suggested Solutions

This article seeks to propel the full implementation of geothermal power plants in Mexico as a renewable energy source.
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, anâ€¦
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.