1Math::NumSeq::ProthNumbUesresr(3C)ontributed Perl DocumeMnattaht:i:oNnumSeq::ProthNumbers(3)
2
3
4

NAME

6       Math::NumSeq::ProthNumbers -- Proth number sequence
7

SYNOPSIS

9        use Math::NumSeq::ProthNumbers;
10        my $seq = Math::NumSeq::ProthNumbers->new;
11        my ($i, $value) = $seq->next;
12

DESCRIPTION

14       The Proth numbers
15
16           3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97, 113, ...
17           starting i=1
18
19       being integers of the form k*2^n+1 for some k and n and where k < 2^n.
20
21       The k < 2^n condition means the values in binary have low half 00..01
22       and high half some value k,
23
24           binary 1xxx0000000...0001
25
26           value    binary        k  n  2^n
27             3       11           1  1   2
28             5       101          1  2   4
29             9      1001          2  2   4
30            13      1101          3  2   4
31            17      10001         2  3   8
32            25      11001         3  3   8
33            33     100001         4  3   8
34            41     101001         5  3   8
35                     ^^
36                     ||
37            k part --++-- low part
38
39       Taking all k < 2^n duplicates some values, as for example 33 is k=4 n=3
40       as 4*2^3+1 and also k=2 n=4 as 2*2^4+1.  This happens for any even k.
41       Incrementing n on reaching k=2^n-1 makes a regular pattern, per "Ith"
42       below.
43

FUNCTIONS

45       See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
46       classes.
47
48       "$seq = Math::NumSeq::ProthNumbers->new()"
49           Create and return a new sequence object.
50
51   Random Access
52       "$value = $seq->ith($i)"
53           Return the $i'th Proth number.  The first number is 3 at "$i==1".
54
55       "$bool = $seq->pred($value)"
56           Return true if $value is a Proth number, meaning is equal to
57           k*2^n+1 for some k and n with k < 2^n.
58
59       "$i = $seq->value_to_i_estimate($value)"
60           Return an estimate of the i corresponding to $value.  This is
61           roughly sqrt(2*$value).
62

FORMULAS

64   Next
65       Successive values can be calculated by keeping track of the 2^n power
66       and incrementing k by adding such a power,
67
68           initial
69             value = 1   # to give 3 on first next() call
70             inc = 2
71             limit = 4
72
73           next()
74             value += inc
75             if value >= limit
76                inc *= 2       # ready for next time
77                limit *= 4
78             return value
79
80   Ith
81       Taking the values by their length in bits, the values are
82
83              11        1 value  i=1
84              101       1 value  i=2
85             1x01       2 values i=3,4
86             1x001      2 values i=5,6
87            1xx001      4 values i=7 to 10
88            1xx0001     4 values
89           1xxx0001     8 values
90           1xxx00001    8 values
91
92       For a given 1xxx high part the low zeros, which is the 2^n factor, is
93       the same length and then repeated 1 bigger.  That doubling can be
94       controlled by a high bit of the i, so in the following Z is either a
95       zero bit or omitted,
96
97              1Z1
98             1xZ01
99            1xxZ001
100           1xxxZ0001
101
102       The ith Proth number can be formed from the bits of the index
103
104           i+1 = 1zxx..xx    binary
105           k = 1xx..xx
106           n = z + 1 + number of x's
107
108       The first 1zxxx desired is 10, which is had from i+1 starting from i=1.
109       The z second highest bit makes n bigger, giving the Z above present or
110       omitted.
111
112       For example i=9 is bits i+1=1010 binary which as 1zxx is k=0b110=6,
113       n=0+1+2=3, for value 6*2^3+1=49, or binary 110001.
114
115       It can be convenient to take the two highest bits of the index i
116       together, so hhxx..xx so hh=2 or 3, then n = hh-1 + number of x's.
117

SEE ALSO

119       Math::NumSeq, Math::NumSeq::CullenNumbers, Math::NumSeq::WoodallNumbers
120

HOME PAGE

122       <http://user42.tuxfamily.org/math-numseq/index.html>
123

LICENSE

125       Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019 Kevin Ryde
126
127       Math-NumSeq is free software; you can redistribute it and/or modify it
128       under the terms of the GNU General Public License as published by the
129       Free Software Foundation; either version 3, or (at your option) any
130       later version.
131
132       Math-NumSeq is distributed in the hope that it will be useful, but
133       WITHOUT ANY WARRANTY; without even the implied warranty of
134       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
135       General Public License for more details.
136
137       You should have received a copy of the GNU General Public License along
138       with Math-NumSeq.  If not, see <http://www.gnu.org/licenses/>.
139
140
141
142perl v5.32.0                      2020-07-28     Math::NumSeq::ProthNumbers(3)
Impressum