Math::PlanePath::DivisibleColumns3pm
Usage
use Math::PlanePath::DivisibleColumns;my $path = Math::PlanePath::DivisibleColumns->new;my ($x, $y) = $path->n_to_xy (123);
Overview
This path visits points X,Y where X is divisible by Y going by columns from Y=1 to Y<=X.
18 | 5717 | 5116 | 4915 | 4414 | 4013 | 3612 | 3411 | 2810 | 269 | 22 568 | 19 487 | 15 396 | 13 33 555 | 9 25 434 | 7 18 32 473 | 4 12 21 31 42 542 | 2 6 11 17 24 30 38 46 531 | 0 1 3 5 8 10 14 16 20 23 27 29 35 37 41 45 50 52Y=0|+---------------------------------------------------------X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Starting N=0 at X=1,Y=1 means the values 1,3,5,8,etc horizontally on Y=1 are the sums
i=Ksum numdivisors(i)i=1
The current implementation is fairly slack and is slow on medium to large N.
Proper Divisors
"divisor_type => 'proper'" gives only proper divisors of X, meaning that Y=X itself is excluded.
9 | 398 | 337 | 266 | 22 385 | 16 294 | 11 21 323 | 7 13 20 28 372 | 3 6 10 15 19 25 31 361 | 0 1 2 4 5 8 9 12 14 17 18 23 24 27 30 34 35Y=0|+---------------------------------------------------------X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
The pattern is the same, but the X=Y line skipped. The high line going up is at Y=X/2, when X is even, that being the highest proper divisor.
N Start
The default is to number points starting N=0 as shown above. An optional "n_start" can give a different start with the same shape, For example to start at 1,
n_start => 19 | 238 | 207 | 166 | 145 | 104 | 8 193 | 5 13 222 | 3 7 12 181 | 1 2 4 6 9 11 15 17 21Y=0|+------------------------------X=0 1 2 3 4 5 6 7 8 9
Functions
See "FUNCTIONS" in Math::PlanePath for behaviour common to all path classes.
- "$path = Math::PlanePath::DivisibleColumns->new ()"
- "$path = Math::PlanePath::DivisibleColumns->new (divisor_type => $str, n_start => $n)"
-
Create and return a new path object.
"divisor_type"(a string) can be"all" (the default)"proper"
- "($x,$y) = $path->n_to_xy ($n)"
-
Return the X,Y coordinates of point number
$non the path. Points begin at 0 and if"$n < 0"then the return is an empty list.
Formulas
Rectangle to N Range
The cumulative divisor count up to and including a given X column can be calculated from the fairly well-known sqrt formula, a sum from 1 to sqrt(X).
S = floor(sqrt(X))/ i=S \numdivs cumulative = 2 * | sum floor(X/i) | - S^2\ i=1 /
This means the N range for 0 to X can be calculated without working out all each column count up to X. In the current code if column counts have been worked out then they're used, otherwise this formula.
Oeis
This pattern is in Sloane's Online Encyclopedia of Integer Sequences in the following forms,
<http://oeis.org/A061017> (etc)
n_start=0 (the default)A006218 N on Y=1 row, cumulative count of divisorsA077597 N on X=Y diagonal, cumulative count divisors - 1n_start=1A061017 X coord, each n appears countdivisors(n) timesA027750 Y coord, list divisors of successive kA056538 X/Y, divisors high to lowdivisor_type=proper (and default n_start=0)A027751 Y coord divisor_type=proper, divisors of successive n(extra initial 1)divisor_type=proper, n_start=2A208460 X-Y, being X subtract each proper divisor
A208460 has "offset" 2, hence "n_start=2" to match that. The same with all divisors would simply insert an extra 0 for the difference at X=Y.
Home page
<http://user42.tuxfamily.org/math-planepath/index.html>
Releases
6 releases since Debian 8 (Jessie); the text changed 3 times.