1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
$ ruby /tmp/primeszp.rb 
/tmp/primeszp.rb:44: warning: assigned but unused variable - rescnt
/tmp/primeszp.rb:85: warning: assigned but unused variable - rescnt
/tmp/primeszp.rb:119: warning: assigned but unused variable - rescnt
/tmp/primeszp.rb:159: warning: assigned but unused variable - rescnt
/tmp/primeszp.rb:165: warning: assigned but unused variable - modk
/tmp/primeszp.rb:212: warning: shadowing outer local variable - p
Rehearsal -------------------------------------------------------------------------
prime tests for P = 20000000000000003   0.000000   0.000000   0.000000 (  0.000004)
Miller-Rabin                            0.010000   0.000000   0.010000 (  0.002646)
primzp7?                               22.310000   0.010000  22.320000 ( 22.371162)
primzp7a?                              17.700000   0.010000  17.710000 ( 17.738696)
primzp7b?                              17.560000   0.020000  17.580000 ( 17.619959)
primzp? 13                             18.920000   0.020000  18.940000 ( 18.979132)
primzp? 17                             20.010000   0.010000  20.020000 ( 20.080455)
primzpa? 13                            20.780000   0.000000  20.780000 ( 20.804851)
primzpa? 17                            26.080000   0.020000  26.100000 ( 28.111176)
factorzp 13                            18.920000   0.010000  18.930000 ( 19.000605)
factorzp 17                            20.210000   0.000000  20.210000 ( 20.313736)
prime? [ruby lib]                      78.380000   0.030000  78.410000 ( 78.755190)
prime_division [ruby lib]              82.240000   0.020000  82.260000 ( 82.734328)
-------------------------------------------------------------- total: 343.270000sec

                                            user     system      total        real
prime tests for P = 20000000000000003   0.000000   0.000000   0.000000 (  0.000005)
Miller-Rabin                            0.000000   0.000000   0.000000 (  0.002065)
primzp7?                               24.210000   0.020000  24.230000 ( 24.522918)
primzp7a?                              18.050000   0.000000  18.050000 ( 18.288376)
primzp7b?                              17.230000   0.000000  17.230000 ( 17.385900)
primzp? 13                             18.600000   0.020000  18.620000 ( 18.735228)
primzp? 17                             19.290000   0.010000  19.300000 ( 19.431852)
primzpa? 13                            20.240000   0.000000  20.240000 ( 20.341052)
primzpa? 17                            24.930000   0.010000  24.940000 ( 25.261765)
factorzp 13                            18.660000   0.010000  18.670000 ( 18.883947)
factorzp 17                            19.320000   0.000000  19.320000 ( 19.561228)
prime? [ruby lib]                      77.910000   0.020000  77.930000 ( 78.635071)
prime_division [ruby lib]              82.760000   0.020000  82.780000 ( 83.599265)


$ jruby /tmp/primeszp.rb 
Rehearsal -------------------------------------------------------------------------
prime tests for P = 20000000000000003   0.010000   0.000000   0.010000 (  0.001000)
Miller-Rabin                            0.370000   0.010000   0.380000 (  0.188000)
primzp7?                                4.370000   0.130000   4.500000 (  4.044000)
primzp7a?                              14.370000   0.150000  14.520000 (  9.309000)
primzp7b?                              16.060000   0.160000  16.220000 ( 10.238000)
primzp? 13                              4.090000   0.020000   4.110000 (  3.636000)
primzp? 17                              3.750000   0.020000   3.770000 (  3.486000)
primzpa? 13                             5.630000   0.010000   5.640000 (  5.426000)
primzpa? 17                             5.670000   0.020000   5.690000 (  5.496000)
factorzp 13                             4.150000   0.010000   4.160000 (  3.945000)
factorzp 17                             4.000000   0.070000   4.070000 (  3.871000)
prime? [ruby lib]                     110.600000   0.160000 110.760000 (109.576000)
prime_division [ruby lib]             110.430000   0.090000 110.520000 (109.919000)
-------------------------------------------------------------- total: 284.350000sec

                                            user     system      total        real
prime tests for P = 20000000000000003   0.000000   0.000000   0.000000 (  0.000000)
Miller-Rabin                            0.070000   0.000000   0.070000 (  0.056000)
primzp7?                                3.630000   0.000000   3.630000 (  3.509000)
primzp7a?                               3.160000   0.000000   3.160000 (  3.156000)
primzp7b?                               3.300000   0.020000   3.320000 (  3.300000)
primzp? 13                              3.080000   0.010000   3.090000 (  3.067000)
primzp? 17                              3.310000   0.040000   3.350000 (  3.299000)
primzpa? 13                             5.340000   0.000000   5.340000 (  5.313000)
primzpa? 17                             5.790000   0.160000   5.950000 (  5.578000)
factorzp 13                             3.700000   0.010000   3.710000 (  3.676000)
factorzp 17                             3.890000   0.030000   3.920000 (  3.812000)
prime? [ruby lib]                     102.360000   0.140000 102.500000 (101.926000)
prime_division [ruby lib]             114.660000   0.180000 114.840000 (113.837000)