// prints all amicable numbers up to 100000 d := func< m | DivisorSigma(1, m) - m >; for m := 2 to 100000 do n := d(m); if d(n) eq m then print m, n; end if; end for;