# 89 arithmetic/tests.for.divisibility/eleven.p

## Description

This article is from the Puzzles FAQ,
by Chris Cole chris@questrel.questrel.com and Matthew Daly
mwdaly@pobox.com with numerous contributions by others.

# 89 arithmetic/tests.for.divisibility/eleven.p

What is the test to see if a number is divisible by eleven?

arithmetic/tests.for.divisibility/eleven.s

If the alternating sum of the digits is divisible by eleven, so is the number.

For example, 1639 leads to 9 - 3 + 6 - 1 = 11, so 1639 is divisible by 11.

Proof:

Every integer n can be expressed as

n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1

where a1, a2, a3, ...a_k+1 are integers between 0 and 9.

10 is congruent to -1 mod(11).

Thus if (-1^k)*a1 + (-1^k-1)*a2 + ...+ (a_k+1) is congruent to 0mod(11) then

n is divisible by 11.

Continue to: