3 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
7 (my $ME = $0) =~ s|.*/||;
9 # A global destructor to close standard output with error checking.
16 warn "$ME: closing standard output: $!\n";
45 or die "$ME: missing argument\n";
47 my $wheel_size = $ARGV[0];
50 my $product = $primes[0];
52 for (my $i = 3; ; $i += 2)
58 ++$n_primes == $wheel_size
63 my $ws_m1 = $wheel_size - 1;
65 /* The first $ws_m1 elements correspond to the incremental offsets of the
66 first $wheel_size primes (@primes). The $wheel_size(th) element is the
67 difference between that last prime and the next largest integer
68 that is not a multiple of those primes. The remaining numbers
69 define the wheel. For more information, see
70 http://www.utm.edu/research/primes/glossary/WheelFactorization.html. */
75 for (my $i = 3; ; $i += 2)
78 foreach my $divisor (@primes)
80 $i != $divisor && $i % $divisor == 0
86 #warn $i, ' ', $i - $prev, "\n";
87 push @increments, $i - $prev;
95 print join (",\n", @increments), "\n";