Math::...Columns(3pm)

πŸ“¦
version 129 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Math::PlanePath::DivisibleColumns β€” X divisible by Y in columns ✨

okay so quick heads up bestie, this whole page lives in the User Contributed Perl Documentation manual (section 3pm), and it's literally just about one path class. She's niche but she's iconic. πŸ’…


🌸 SYNOPSIS 🌸

use Math::PlanePath::DivisibleColumns;
my $path = Math::PlanePath::DivisibleColumns->new;
my ($x, $y) = $path->n_to_xy (123);

πŸ¦‹ DESCRIPTION πŸ¦‹

So this path visits the points X,Y where X is divisible by Y, and it does that by going column by column from Y=1 up to Y<=X. Simple as that, no cap. πŸ’―

   18 |                                                      57
   17 |                                                   51
   16 |                                                49
   15 |                                             44
   14 |                                          40
   13 |                                       36
   12 |                                    34
   11 |                                 28
   10 |                              26
    9 |                           22                         56
    8 |                        19                      48
    7 |                     15                   39
    6 |                  13                33                55
    5 |                9             25             43
    4 |             7          18          32          47
    3 |          4       12       21       31       42       54
    2 |       2     6    11    17    24    30    38    46    53
    1 |    0  1  3  5  8 10 14 16 20 23 27 29 35 37 41 45 50 52
   Y=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., going horizontally along Y=1 are those sums, like:

     i=K
    sum   numdivisors(i)
     i=1
ngl the current implementation is fairly slack and slow on medium to large N. she's not built for speed, she's built for vibes. 🐌

πŸŽ€ Proper Divisors πŸŽ€

Passing "divisor_type => 'proper'" gives you only the proper divisors of X, which means Y=X itself gets left out of the party. sorry X, not you this time. πŸ™ˆ

    9 |                                                      39
    8 |                                                33
    7 |                                          26
    6 |                                    22                38
    5 |                              16             29
    4 |                        11          21          32
    3 |                   7       13       20       28       37
    2 |             3     6    10    15    19    25    31    36
    1 |       0  1  2  4  5  8  9 12 14 17 18 23 24 27 30 34 35
   Y=0|
      +---------------------------------------------------------
      X=0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18

The pattern stays the same, it's just the X=Y line that gets skipped. The high line going up sits at Y=X/2, when X is even, and that's the highest proper divisor. 🫢


✨ N Start ✨

Default behaviour is numbering points starting at N=0 like you saw up there. But you can hand over an optional "n_start" to kick things off at a different number while keeping the exact same shape. For example, to start at 1:

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

πŸ‘‘ FUNCTIONS πŸ‘‘

Heads up, bestie: see "FUNCTIONS" in Math::PlanePath for the behaviour that's common to all path classes. This one is not special like that. πŸ’œ

  • $path = Math::PlanePath::DivisibleColumns->new ()
  • $path = Math::PlanePath::DivisibleColumns->new (divisor_type => $str, n_start => $n)

Makes you a brand new path object and hands it over. The "divisor_type" thing (it's a string) can be one of:

"all"       (the default)
"proper"
  • ($x,$y) = $path->n_to_xy ($n)

Gives you back the X,Y coordinates of point number $n on the path. Points start at 0, and if "$n < 0" then you just get an empty list back. it's giving "no thoughts, empty list". 😭


🧚 FORMULAS 🧚

πŸ’« Rectangle to N Range πŸ’«

The cumulative divisor count, up to and including a given X column, can be worked out from the pretty 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             /

So basically the N range for 0 to X can be calculated without grinding out every single column count up to X. In the current code, if column counts have already been worked out then they get used, otherwise it's this formula. lowkey efficient. ⭐


🌈 OEIS 🌈

This pattern shows up 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 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

Fun fact bestie: A208460 has "offset" 2, which is exactly why you'd use "n_start=2" to match it. Doing the same with all divisors would just slip in an extra 0 for the difference at X=Y. iykyk. πŸ’…


πŸ“ SEE ALSO πŸ“

  • Math::PlanePath
  • Math::PlanePath::CoprimeColumns

🫢 HOME PAGE 🫢

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


πŸ’€ 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/>.


and that's the whole page, bestie, you ate it. πŸŽ€ this one's perl v5.32.0, dated 2021-01-23, and it's the Math::...Columns(3pm) page from the User Contributed Perl Documentation. slay, go forth and divide. βœ¨πŸ’–πŸ¦‹