View Single Post
Old 2021-08-28, 12:00   #47
robert44444uk's Avatar
Jun 2003
Oxford, UK

19·103 Posts

Originally Posted by CraigLo View Post

The algorithm:

2. Precompute ord(p) for all primes.

Any thoughts?
In Perl, the function znorder is quite quick. Up to 2^31 the following Perl program was run on my standard desktop in 304.5 seconds, suggesting about 12 minutes for 2^31.5.

#!/usr/bin/env perl
use warnings;
use strict;
use Math::Prime::Util qw/:all/;
use Time::HiRes qw(gettimeofday tv_interval);

my $start = 2;
my $end = 2**31;
my $starttime = [gettimeofday];
my $x;

forprimes {$x = znorder(2, $_);} $start, $end;

my $duration = tv_interval($starttime);
printf("Execution time: %.2fs\n", $duration);
robert44444uk is offline   Reply With Quote