Math-PlanePath

 view release on metacpan or  search on metacpan

lib/Math/PlanePath/DivisibleColumns.pm  view on Meta::CPAN

       +---------------------------------------------------------
       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.

=head2 N Start

The default is to number points starting N=0 as shown above.  An optional
C<n_start> can give a different start with the same shape,  For example
to start at 1,

=cut

# math-image --path=DivisibleColumns,n_start=1 --all --output=numbers --size=50x16

=pod

    n_start => 1

     9 |                           23
     8 |                        20
     7 |                     16
     6 |                  14
     5 |               10
     4 |             8          19
     3 |          5       13       22
     2 |       3     7    12    18
     1 |    1  2  4  6  9 11 15 17 21
    Y=0|
       +------------------------------
       X=0  1  2  3  4  5  6  7  8  9

=head1 FUNCTIONS

See L<Math::PlanePath/FUNCTIONS> for behaviour common to all path classes.

=over 4

=item C<$path = Math::PlanePath::DivisibleColumns-E<gt>new ()>

=item C<$path = Math::PlanePath::DivisibleColumns-E<gt>new (divisor_type =E<gt> $str, n_start =E<gt> $n)>

Create and return a new path object.  C<divisor_type> (a string) can be

    "all"       (the default)
    "proper"

=item C<($x,$y) = $path-E<gt>n_to_xy ($n)>

Return the X,Y coordinates of point number C<$n> on the path.  Points begin
at 0 and if C<$n E<lt> 0> then the return is an empty list.

=back

=head1 FORMULAS

=head2 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.

=head1 OEIS

This pattern is in Sloane's Online Encyclopedia of Integer Sequences in the
following forms,

=over

L<http://oeis.org/A061017> (etc)

=back

    n_start=0 (the default)
      A006218    N on Y=1 row, cumulative count of divisors
      A077597    N on X=Y diagonal, cumulative count divisors - 1

    n_start=1
      A061017    X coord, each n appears countdivisors(n) times
      A027750    Y coord, list divisors of successive k
      A056538    X/Y, divisors high to low

    divisor_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=2
      A208460    X-Y, being X subtract each proper divisor

A208460 has "offset" 2, hence C<n_start=2> to match that.  The same with
all divisors would simply insert an extra 0 for the difference at X=Y.

=head1 SEE ALSO

L<Math::PlanePath>,
L<Math::PlanePath::CoprimeColumns>

=head1 HOME PAGE

L<http://user42.tuxfamily.org/math-planepath/index.html>

=head1 LICENSE

Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Kevin Ryde

Math-PlanePath is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

Math-PlanePath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.

=cut



( run in 0.465 second using v1.01-cache-2.11-cpan-df04353d9ac )