12.21

From The Algorithm Design Manual Solution Wiki
Jump to navigation Jump to search

Let the ten multiples be written as [math]x=11a[/math] and [math]y=11b[/math] with [math]a,b\in\{1,2,\dots ,10\}[/math].
Because [math]\gcd(11a,11b)=11\gcd(a,b)[/math], we get [math]\gcd(x,y)=11[/math] exactly when [math]\gcd(a,b)=1[/math].

1. Choose two distinct indices [math]a,b[/math] from 1 – 10.
  • Total unordered pairs: [math]\binom{10}{2}=45[/math].
  • Pairs with [math]\gcd(a,b)=1[/math]: 32 (found by direct count or a short program).

2. Therefore
[math]\displaystyle P(\gcd(x,y)=11)=\frac{32}{45}\;.[/math]

Python check

from math import gcd
cnt = 0
for a in range(1,11):
    for b in range(a+1,11):
        if gcd(a,b)==1:
            cnt += 1
print(cnt,"/",45)

The script prints 32 / 45, confirming the result.


Back to Chapter 12