4 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
8 (my $program_name = $0) =~ s
|.*/||;
13 # This is required if the code might send any output to stdout
14 # E.g., even --version or --help. So it's best to do it unconditionally.
16 or (warn "$program_name: closing standard output: $!\n"), _exit
(1);
44 or die "$program_name: missing argument\n";
46 my $wheel_size = $ARGV[0];
49 my $product = $primes[0];
51 for (my $i = 3; ; $i += 2)
57 ++$n_primes == $wheel_size
62 my $ws_m1 = $wheel_size - 1;
64 /* The first $ws_m1 elements correspond to the incremental offsets of the
65 first $wheel_size primes (@primes). The $wheel_size(th) element is the
66 difference between that last prime and the next largest integer
67 that is not a multiple of those primes. The remaining numbers
68 define the wheel. For more information, see
69 http://www.utm.edu/research/primes/glossary/WheelFactorization.html. */
74 for (my $i = 3; ; $i += 2)
77 foreach my $divisor (@primes)
79 $i != $divisor && $i % $divisor == 0
85 #warn $i, ' ', $i - $prev, "\n";
86 push @increments, $i - $prev;
94 print join (",\n", @increments), "\n";