* Riley <[EMAIL PROTECTED]> [2004-08-02 16:51]:
> It reminds me of someone's clever way of determining if a number is prime,
> which (at least in my version) turns out to be of similar length:
> 
> -l print 0|(1x pop)!~/^(11+)\1+$/
> 
> I'm writing the above from memory, so I'm not sure if it's exact. Does
> anyone know the origin of this algorithm? Was it the result of some ancient
> golf?

The first time I ever saw it was in a JAPH by Abigail:

perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'

found here: http://www.cpan.org/misc/japh

-- Mike

-- 
Michael W. Thelen
Progress, far from consisting in change, depends on retentiveness.  Those who
cannot remember the past are condemned to repeat it.
                -- George Santayana, "Life of Reason"

Attachment: signature.pgp
Description: Digital signature

Reply via email to