Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

(´∀`) Prime numbers (,,゚Д゚)

Name: Anonymous 2007-04-15 11:11 ID:00E9fssW

|code]isPrime x = (filter (0 ==) (map (mod x) [2..x-1])) == [][/code]

Name: Anonymous 2007-04-15 11:41 ID:1BpXn22L

sub is_prime{$_='x'x pop;/../^/^(..+)\1+$/}

or, if you want something a little faster:
sub is_prime{my$n=pop;map{$n*=$n%$_>0}2..$n**.5;$n>1}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List