Why do perfect numbers end in 6 or 8?
This is only true for even perfect numbers; there is no proof that there are no odd perfect numbers, but if one does exist, it has been proved to be in excess of 101500.All even perfect numbers are of the form 2p-1(2p - 1) where 2p-1 is a Mersenne prime - if p is not a prime number, 2p - 1 is also not a prime number (but if p is prime, 2p - 1 may, or may not, be prime).Firstly, other than 2 all primes are odd numbers. So we'll deal with the case when p = 2 separately now:22 - 1 = 3 which is prime, so 22-1(22-1) = 2 x 3 = 6 is a perfect number and does indeed end in 6 (it is 6).To show that all even perfect numbers must end in 6 or 8 when p is an odd prime number requires the use of modulo arithmetic which considers the remainders when numbers are divided by other numbers. In fact, your question is using modulo arithmetic: you are asking why when all [even] perfect numbers are divided by 10 the remainder is always 6 or 8. In mathematical terms this is "why are all [even] perfect numbers modulo 10 equivalent to 6 or 8".Modulo arithmetic is written:a ≡ b mod nmeaning that when a is divided by n the remainder is b and is read "a is equivalent to b modulo n". This can also be written as:a = kn + b for some integer k.examples:24 ≡ 4 mod 10 since 24 = 2 x 10 + 419 ≡ 4 mod 5 since 19 = 3 x 5 + 420 ≡ 0 mod 4 since 20 = 5 x 4 + 0We now need to work out the value ofab ≡ ? mod ngiven that:a ≡ r mod n → a = kn + r (for some k)b ≡ s mod n → b = jn + s (for some j)So:ab = (kn + r)(jn + s)= kjn2 + ksn + rjn + rs= (kjn + ks + rj)n + rs= tn + rs (where t = kjn + ks + rj)→ ab ≡ rs mod nie multiply their modulo equivalences together. [Result 1]if b = a, then this becomes a2 ≡ r2 mod n, ie ax ≡ rx mod n [Result 2]So, going back to the formula for even prefect numbers, we want to know it to modulo 10, so we have:Given:2p-1 ≡ r mod 10(2p - 1) ≡ s mod 10then (from Result 1)2p-1(2p - 1) ≡ rs mod 10 [Result 3]So now we need to look at the results of the powers of 2 modulo 10:(21 = 2) ≡ 2 mod 10(22 = 21 x 2) ≡ (2 x 2 = 4) mod 10(23 = 22 x 2) ≡ (2 x 4 = 8) mod 10(24 = 23 x 2) ≡ (2 x 8 = 16 ≡ 6) mod 10(25 = 24 x 2) ≡ (2 x 6 = 12 ≡ 2) mod 10(26 = 25 x 2) ≡ (2 x 2 = 4) mod 10...You should notice that at this point, that the modulo repeat the four digits 2, 4, 8, 6, 2, 4, 8, 6, ...; so a quick way to find out the last digit of a power of 2 is to take the power modulo 4 and look at that digit of the sequence, but if this is 0, then the 4th digit of the sequence (6) is the result [Result 4]We're almost there, now for the final proof:As p is an odd number (as we are only considering the primes other than 2 (dealt with separately above) and as such they must be odd), it is such that p = 2n + 1 for some integer n, giving:2p-1(2p - 1) = 22n+1-1(22n+1 - 1)= 22n(22n+1 - 1)Using result 3 (and 1) above, we can calculate the remainder of this divided by 10, by multiplying together the remainder of each part divided by 10:22n2n is an even number. Using result 4 above, when this is divided by 4, the remainder is going to be even (2 ≡ 2 mod 4 which is even, and multiplying this by any number will always result in an even number), so 22n ≡ 4 or 6 mod 10. 22n+1 - 122n+1 = 2 x 22n, so 22n+1 - 1 is one less than the next digit in the sequence (of result 4) that gave 22n, ie one less than 8 or 2 respectively. So if:22n ≡ 4 mod 10 → 22n+1 ≡ 8 mod 10→ 22n(22n+1 - 1) ≡ [4 x (8-1) = 28 ≡] 8 mod 1022n ≡ 6 mod 10 → 22n+1 ≡ 2 mod 10→ 22n(22n+1 - 1) ≡ [6 x (2-1) =] 6 mod 10Thus all even perfect numbers end in 8 or 6.QED.