|
#!/bin/perl
srand($ARGV[0] + $ $^ time); rand();
sub round { my ($n,$d) = @_;
return int($n/(10**$d)+.5*($n <=> 0))*(10**$d);
}
sub RoundXL { sprintf("%.$_[1]f", $_[0]);}
$avg= &RoundXL($avg, 3);
print "SoSu=(".join(",",&SoSu(10000)).")\n";
for($n=1100;$n<1200;$n+=1) { print "$n=(".join(",",&SoInSu($n)).")\n";}
sub SoSu{my($m)=@_;my@o;I:for(my$i=2;$i<$m;$i++){foreach$n(@o){if($i%$n==0){next I;}}push(@o,$i);}@o;}
sub SoInSu{my($n)=@_;my@o;for(my$i=2;$i<=$n;$i++){while($n%$i==0){push(@o,$i);$n/=$i;}}@o;}
sub GCD{my($a,$b)=@_;while($b!=0){$t=$b;$b=$a%$b;$a=$t;}$a;}
sub LCM{my($a,$b)=@_;return$a*$b/&GCD($a,$b);}
sub YakBun{my($a,$b)=@_;my$c=&GCD($a,$b);($a/$c,$b/$c);} |
|