A random collection of things I come across.
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/' [number]See http://montreal.pm.org/tech/neil_kandalgaonkar.shtml for an explanationof how it works. It basically involves backtracking.
No comments:
Post a Comment