Custom Search
|
Ken Iverson, the inventor of APL, has been credited with a one-liner that, given a number N, produces a list of the prime numbers from 1 to N inclusive. It looks like this:
(2 = 0 +.= T o.| T) / T <- iN
where `o' is the APL null character, the assignment arrow is a single character, and `i' represents the APL iota.
Here's a Perl program that prints primes:
perl -le '$_ = 1; (1 x $_) !~ /^(11+)\1+$/ && print while $_++'
|
12 hits in May 2012 mes@science.uva.nl |