#!/usr/bin/perl # This is a very ugly way to get primes. Warning, it runs forever, # until you 'kill -TERM' it because the second # condition of $x is simply that it is larger than 0, which it will always be. # Assumes you have 'factor' installed, which any Linux system should. # Creates a file called log.txt with the list of primes, one per line. # This program is hereby put into the Public Domain for ($x=1;$x>0;$x=($x+2)){ # we only check odd numbers if(`factor $x|grep '$x: $x'`){ open(LOG,">>log.txt"); print LOG "$x\n"; close(LOG); } } 1;