Prove that if n is not divisible by 3 then n^2+2 is divisible by 3

For the value of n, we have 3 choices

Case 1 : n % 3 = 1

Let,

P = (n2+2) % 3

P = ( ( n2 ) % 3 + 2 % 3 ) % 3

P = ( ( n % 3 ) ( n % 3 ) + 2 ) % 3

P = ( 1 * 1 + 2 ) % 3

P = 3 % 3

P = 0

Therefore, n2+2 is divisible by 3 if n % 3 = 1

Case 2 : n % 3 = 2

Let,

P = (n2+2) % 3

P = ( ( n2 ) % 3 + 2 % 3 ) % 3

P = ( ( n % 3 ) ( n % 3 ) + 2 ) % 3

P = ( 2 * 2+ 2 ) % 3

P = 6 % 3

P = 0

Therefore, n2+2 is divisible by 3 if n % 3 = 2

Case 2 : n % 3 = 0

P = (n2+2) % 3

P = ( ( n2 ) % 3 + 2 % 3 ) % 3

P = ( ( n % 3 ) ( n % 3 ) + 2 ) % 3

P = ( 0 * 0+ 2 ) % 3

P = 2

Therefore, n2+2 is not divisible by 3 if n % 3 = 0

From above cases, we can conclude that n2+2 is divisible by 3 if and only if n is not divisible by 3.

Leave a Comment

Your email address will not be published. Required fields are marked *