1Math::PlanePath::DivisiUbsleerCoClounmtnrsi(b3u)ted PerlMaDtohc:u:mPelnatnaetPiaotnh::DivisibleColumns(3)
2
3
4
6 Math::PlanePath::DivisibleColumns -- X divisible by Y in columns
7
9 use Math::PlanePath::DivisibleColumns;
10 my $path = Math::PlanePath::DivisibleColumns->new;
11 my ($x, $y) = $path->n_to_xy (123);
12
14 This path visits points X,Y where X is divisible by Y going by columns
15 from Y=1 to Y<=X.
16
17 18 | 57
18 17 | 51
19 16 | 49
20 15 | 44
21 14 | 40
22 13 | 36
23 12 | 34
24 11 | 28
25 10 | 26
26 9 | 22 56
27 8 | 19 48
28 7 | 15 39
29 6 | 13 33 55
30 5 | 9 25 43
31 4 | 7 18 32 47
32 3 | 4 12 21 31 42 54
33 2 | 2 6 11 17 24 30 38 46 53
34 1 | 0 1 3 5 8 10 14 16 20 23 27 29 35 37 41 45 50 52
35 Y=0|
36 +---------------------------------------------------------
37 X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
38
39 Starting N=0 at X=1,Y=1 means the values 1,3,5,8,etc horizontally on
40 Y=1 are the sums
41
42 i=K
43 sum numdivisors(i)
44 i=1
45
46 The current implementation is fairly slack and is slow on medium to
47 large N.
48
50 "divisor_type => 'proper'" gives only proper divisors of X, meaning
51 that Y=X itself is excluded.
52
53 9 | 39
54 8 | 33
55 7 | 26
56 6 | 22 38
57 5 | 16 29
58 4 | 11 21 32
59 3 | 7 13 20 28 37
60 2 | 3 6 10 15 19 25 31 36
61 1 | 0 1 2 4 5 8 9 12 14 17 18 23 24 27 30 34 35
62 Y=0|
63 +---------------------------------------------------------
64 X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
65
66 The pattern is the same, but the X=Y line skipped. The high line going
67 up is at Y=X/2, when X is even, that being the highest proper divisor.
68
69 N Start
70 The default is to number points starting N=0 as shown above. An
71 optional "n_start" can give a different start with the same shape, For
72 example to start at 1,
73
74 n_start => 1
75
76 9 | 23
77 8 | 20
78 7 | 16
79 6 | 14
80 5 | 10
81 4 | 8 19
82 3 | 5 13 22
83 2 | 3 7 12 18
84 1 | 1 2 4 6 9 11 15 17 21
85 Y=0|
86 +------------------------------
87 X=0 1 2 3 4 5 6 7 8 9
88
90 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
91 classes.
92
93 "$path = Math::PlanePath::DivisibleColumns->new ()"
94 "$path = Math::PlanePath::DivisibleColumns->new (divisor_type => $str,
95 n_start => $n)"
96 Create and return a new path object. "divisor_type" (a string) can
97 be
98
99 "all" (the default)
100 "proper"
101
102 "($x,$y) = $path->n_to_xy ($n)"
103 Return the X,Y coordinates of point number $n on the path. Points
104 begin at 0 and if "$n < 0" then the return is an empty list.
105
107 Rectangle to N Range
108 The cumulative divisor count up to and including a given X column can
109 be calculated from the fairly well-known sqrt formula, a sum from 1 to
110 sqrt(X).
111
112 S = floor(sqrt(X))
113 / i=S \
114 numdivs cumulative = 2 * | sum floor(X/i) | - S^2
115 \ i=1 /
116
117 This means the N range for 0 to X can be calculated without working out
118 all each column count up to X. In the current code if column counts
119 have been worked out then they're used, otherwise this formula.
120
122 This pattern is in Sloane's Online Encyclopedia of Integer Sequences in
123 the following forms,
124
125 <http://oeis.org/A061017> (etc)
126
127 n_start=0 (the default)
128 A006218 N on Y=1 row, cumulative count of divisors
129 A077597 N on X=Y diagonal, cumulative count divisors - 1
130
131 n_start=1
132 A061017 X coord, each n appears countdivisors(n) times
133 A027750 Y coord, list divisors of successive k
134 A056538 X/Y, divisors high to low
135
136 divisor_type=proper (and default n_start=0)
137 A027751 Y coord divisor_type=proper, divisors of successive n
138 (extra initial 1)
139
140 divisor_type=proper, n_start=2
141 A208460 X-Y, being X subtract each proper divisor
142
143 A208460 has "offset" 2, hence "n_start=2" to match that. The same with
144 all divisors would simply insert an extra 0 for the difference at X=Y.
145
147 Math::PlanePath, Math::PlanePath::CoprimeColumns
148
150 <http://user42.tuxfamily.org/math-planepath/index.html>
151
153 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde
154
155 Math-PlanePath is free software; you can redistribute it and/or modify
156 it under the terms of the GNU General Public License as published by
157 the Free Software Foundation; either version 3, or (at your option) any
158 later version.
159
160 Math-PlanePath is distributed in the hope that it will be useful, but
161 WITHOUT ANY WARRANTY; without even the implied warranty of
162 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
163 General Public License for more details.
164
165 You should have received a copy of the GNU General Public License along
166 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
167
168
169
170perl v5.28.1 2017-12-0M3ath::PlanePath::DivisibleColumns(3)