问题

软件 >> ARIBAS
Questions in category: ARIBAS (aribas).

将整数作因子分解

Posted by haifeng on 2016-01-12 17:17:34 last update 2016-01-12 17:21:49 | Answers (0) | 收藏


==> x:=1023;

while q:=factor16(x) do
    writeln(q);
    x:=x div q;
end;
x.


Then the ARIBAS will display the divisors of x:


3
11
-: 31


 

需要注意的是, factor16(x) 这个函数返回 x 的小于 min(2**16,x) 的最小素因子, 如果这样的素因子存在的话. 如果不存在小于 min(2**16,x) 的素因子, 则返回 0. 因此这里的 while 循环会一直运行到 x 是素数为止或在 2**16 以下没有找到素因子则终止.