大意就是给出了一个很大的数(6K亿) ,然后求它最大的素因子
这题的话用的是sqrt(n)的算法
n=”the evil big number”
if n mod 2=0
then
lastFactor=2
n=n div 2
while n mod 2=0
n=n div 2
else
lastFactor=1
factor=3
maxFactor= n
while n>1 and factor<=maxFactor
if n mod factor=0
then
n=n div factor
lastFactor=factor
while n mod factor=0
n=n div factor
maxFactor= n
factor=factor+2
if n=1
then
output lastFactor
else
output n
官方给的方法就是上面的方法了。
不过我要是提前筛出sqrt(n)的素数。然后直接枚举素数的话
也不知道能不能快多少