#! /usr/bin/perl use Math::BigInt ':constant'; my $i; my $target; my $flta; my $fltb; my $base; my $exp; my $i=1; for $target(1...560){ flt($target); print "$target is prime number $i"; if ($i==560){print "From $target and greater are the appearance of Carmichael numbers,other primality tests are required.";} sub flt{ $target=shift @_; $exp=$target -1; PRIMALITY: for $base(1..$exp){ $flta=$base**$exp; $fltb=$flta%$target; if ($fltb==1){ next PRIMALITY; }else{ last} $i=$i+1; return $target; }