Re: Triangles and More

Michael W Thelen <[email protected]> Mon, 2 Aug 2004 23:04:25 -0600
Newsgroups gmane.comp.lang.perl.golf
Message-ID <[email protected]>
* 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"
signature.pgp (application/pgp-signature, 189 B) - not displayed