in reply to Avoid keeping larger lists in Memory
I would just add the possibility to take yet optimized code from CPAN: Math::Prime::Util (or Math::Prime::Util::GMP directly for big numbers.. but see also..)
From examples:
# Project Euler, problem 3 (Largest prime factor) use Math::Prime::Util qw/factor/; use bigint; # Only necessary for 32-bit machines. say 0+(factor(600851475143))[-1]
PS wow it returns in no time!:
perl -Mbigint -E "use Math::Prime::Util::GMP qw(factor); say 0+(factor +(600851475143600851475143600851475143))[ -1]" 999999000001 # ~1 second to get the largest factor of: # 60085147514360085147514360085147514300851475143008514751430085147514 +30085147514300851475143 834789126661809633627036527926883609177018602883402075695455196267
L*
|
|---|