Answer

问题及解答

编程寻找 amicable 数对

Posted by haifeng on 2011-08-10 16:44:13 last update 2011-08-13 10:18:58 | Edit | Answers (0)

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

这里函数 DivisorSigma(i,n) 的功能是:

\[ \sigma_i(n)=\sum_{d|n}d^i \]