[libmath-prime-util-perl] 22/43: Add xt nth_twin_prime test

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:53:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.40
in repository libmath-prime-util-perl.

commit 7cf90ba679fb6648ed66477f90f9407c0dd2f635
Author: Dana Jacobsen <dana at acm.org>
Date:   Fri Mar 28 16:21:23 2014 -0700

    Add xt nth_twin_prime test
---
 xt/nth_twin_prime.t | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/xt/nth_twin_prime.t b/xt/nth_twin_prime.t
new file mode 100644
index 0000000..b40d2f6
--- /dev/null
+++ b/xt/nth_twin_prime.t
@@ -0,0 +1,67 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use Test::More;
+use Math::Prime::Util qw/twin_prime_count nth_twin_prime/;
+
+# 2^n using primesieve (fast), double checked with Pari 2.7.0 (slow):
+#   a(n)=my(s, p=2); forprime(q=3, 2^n, if(q-p==2, s++); p=q); s
+#   for (i=1,35,print(2^i," ", a(i)))
+# 10^n from tables
+my %nthvals = (
+         0 =>           0,
+         1 =>           3,
+         2 =>           5,
+         3 =>          11,
+         5 =>          29,
+         7 =>          59,
+         8 =>          71,
+        10 =>         107,
+        17 =>         239,
+        24 =>         461,
+        35 =>         881,
+        36 =>        1019,
+        62 =>        2027,
+       107 =>        4091,
+       177 =>        8087,
+       205 =>        9929,
+       290 =>       16361,
+       505 =>       32717,
+       860 =>       65519,
+      1224 =>       99989,
+      1526 =>      131009,
+      2679 =>      262109,
+      4750 =>      524219,
+      8169 =>      999959,
+      8535 =>     1048571,
+     15500 =>     2097131,
+     27995 =>     4193801,
+     50638 =>     8388449,
+     58980 =>     9999971,
+     92246 =>    16777139,
+    168617 =>    33554009,
+    309561 =>    67108667,
+    440312 =>    99999587,
+    571313 =>   134217437,
+   1056281 =>   268435007,
+   1961080 =>   536870837,
+   3424506 =>   999999191,
+   3650557 =>  1073741717,
+   6810670 =>  2147482949,
+  12739574 =>  4294965839,
+  23878645 =>  8589934289,
+  27412679 =>  9999999701,
+  44849427 => 17179868807,
+  84384508 => 34359737297,
+  159082253 => 68719476389,
+  224376048 => 99999999761,
+ 1870585220 => 999999999959,
+);
+
+plan tests => scalar(keys %nthvals);
+
+foreach my $n (sort {$a <=> $b} keys %nthvals) {
+  my $ntp = $nthvals{$n};
+  is( nth_twin_prime($n), $ntp, "nth_twin_prime($n) = $ntp" );
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list