| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 2011, 2012, 2013, 2014 Kevin Ryde |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Math-NumSeq. |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Math-NumSeq is free software; you can redistribute it and/or modify |
|
6
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the |
|
7
|
|
|
|
|
|
|
# Free Software Foundation; either version 3, or (at your option) any later |
|
8
|
|
|
|
|
|
|
# version. |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Math-NumSeq is distributed in the hope that it will be useful, but |
|
11
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
12
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13
|
|
|
|
|
|
|
# for more details. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
|
16
|
|
|
|
|
|
|
# with Math-NumSeq. If not, see . |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Math::NumSeq::PrimeIndexOrder; |
|
19
|
1
|
|
|
1
|
|
9632
|
use 5.004; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
54
|
|
|
20
|
1
|
|
|
1
|
|
9
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
41
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use vars '$VERSION', '@ISA'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
105
|
|
|
23
|
|
|
|
|
|
|
$VERSION = 71; |
|
24
|
1
|
|
|
1
|
|
8
|
use Math::NumSeq; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
55
|
|
|
25
|
|
|
|
|
|
|
@ISA = ('Math::NumSeq'); |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
14
|
use Math::NumSeq::Primes; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
70
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
|
31
|
|
|
|
|
|
|
#use Smart::Comments; |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
13
|
use constant name => Math::NumSeq::__('Prime Index Order'); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
13
|
|
|
34
|
1
|
|
|
1
|
|
5
|
use constant description => Math::NumSeq::__('An order of primeness, being how many steps of prime at prime index until reaching a composite.'); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
10
|
|
|
35
|
1
|
|
|
1
|
|
7
|
use constant characteristic_count => 1; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
36
|
1
|
|
|
1
|
|
5
|
use constant characteristic_smaller => 1; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
37
|
1
|
|
|
1
|
|
6
|
use constant characteristic_increasing => 0; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
103
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
11
|
use constant parameter_info_array => |
|
40
|
|
|
|
|
|
|
[ |
|
41
|
|
|
|
|
|
|
{ name => 'on_values', |
|
42
|
|
|
|
|
|
|
share_key => 'on_values_primes', |
|
43
|
|
|
|
|
|
|
display => Math::NumSeq::__('On Values'), |
|
44
|
|
|
|
|
|
|
type => 'enum', |
|
45
|
|
|
|
|
|
|
default => 'all', |
|
46
|
|
|
|
|
|
|
choices => ['all','primes'], |
|
47
|
|
|
|
|
|
|
choices_display => [Math::NumSeq::__('All'), |
|
48
|
|
|
|
|
|
|
Math::NumSeq::__('Primes')], |
|
49
|
|
|
|
|
|
|
description => Math::NumSeq::__('Values to act on, either all integers or just the primes.'), |
|
50
|
|
|
|
|
|
|
}, |
|
51
|
1
|
|
|
1
|
|
5
|
]; |
|
|
1
|
|
|
|
|
2
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my %values_min = (all => 0, |
|
54
|
|
|
|
|
|
|
primes => 1); |
|
55
|
|
|
|
|
|
|
sub values_min { |
|
56
|
2
|
|
|
2
|
1
|
20
|
my ($self) = @_; |
|
57
|
2
|
|
|
|
|
10
|
return $values_min{$self->{'on_values'}}; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my %oeis_anum = (primes => 'A049076', |
|
61
|
|
|
|
|
|
|
# OEIS-Catalogue: A049076 on_values=primes |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
sub oeis_anum { |
|
64
|
2
|
|
|
2
|
1
|
11
|
my ($self) = @_; |
|
65
|
2
|
|
|
|
|
6
|
return $oeis_anum{$self->{'on_values'}}; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub rewind { |
|
69
|
6
|
|
|
6
|
1
|
1782
|
my ($self) = @_; |
|
70
|
6
|
|
|
|
|
28
|
$self->{'i'} = $self->i_start; |
|
71
|
6
|
|
|
|
|
37
|
my $seq = Math::NumSeq::Primes->new; |
|
72
|
6
|
|
|
|
|
19
|
$self->{'seqs'} = [ $seq ]; |
|
73
|
6
|
|
|
|
|
84
|
$seq->next; |
|
74
|
6
|
|
|
|
|
33
|
$self->{'targets'} = [ 2 ]; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub next { |
|
78
|
48
|
|
|
48
|
1
|
1581
|
my ($self) = @_; |
|
79
|
|
|
|
|
|
|
### PrimeIndexOrder next(): $self->{'i'} |
|
80
|
|
|
|
|
|
|
|
|
81
|
48
|
|
|
|
|
83
|
my $i = $self->{'i'}++; |
|
82
|
48
|
|
|
|
|
78
|
my $targets = $self->{'targets'}; |
|
83
|
|
|
|
|
|
|
|
|
84
|
48
|
|
|
|
|
69
|
my $level = 0; |
|
85
|
48
|
|
|
|
|
52
|
my $k; |
|
86
|
48
|
100
|
|
|
|
142
|
if ($self->{'on_values'} ne 'primes') { |
|
87
|
34
|
100
|
|
|
|
149
|
if ($i < $targets->[0]) { |
|
88
|
20
|
|
|
|
|
53
|
return ($i, 0); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
28
|
|
|
|
|
346
|
for (;;) { |
|
93
|
56
|
|
|
|
|
186
|
($k, $targets->[$level]) = $self->{'seqs'}->[$level]->next; |
|
94
|
56
|
|
|
|
|
72
|
$k--; |
|
95
|
56
|
100
|
|
|
|
145
|
if ($level >= $#$targets) { |
|
96
|
16
|
|
|
|
|
74
|
my $seq = Math::NumSeq::Primes->new; |
|
97
|
16
|
|
|
|
|
32
|
push @{$self->{'seqs'}}, $seq; |
|
|
16
|
|
|
|
|
36
|
|
|
98
|
16
|
|
|
|
|
134
|
(undef, $targets->[$level+1]) = $seq->next; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
56
|
|
|
|
|
147
|
$level++; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
### $k |
|
103
|
|
|
|
|
|
|
### $level |
|
104
|
|
|
|
|
|
|
|
|
105
|
56
|
100
|
|
|
|
359
|
if ($k < $targets->[$level]) { |
|
106
|
28
|
|
|
|
|
92
|
return ($i, $level); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub pred { |
|
112
|
24
|
|
|
24
|
1
|
304
|
my ($self, $value) = @_; |
|
113
|
24
|
|
33
|
|
|
98
|
return ($value == int($value) |
|
114
|
|
|
|
|
|
|
&& $value >= 0); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
|
118
|
|
|
|
|
|
|
__END__ |