Math::N...oPeriod(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

πŸ’– Math::N...oPeriod(3) πŸ’–

okay bestie so you're reading the Perl manpage for Math::NumSeq::PisanoPeriod β€” it's a User Contributed Perl Documentation page and honestly? it's giving math girlie main character energy. it's called Math::N...oPeriod(3) in the header bc the terminal is dramatic and truncates things, but we know her real name. let's get into it πŸ’…


✨ NAME ✨

Math::NumSeq::PisanoPeriod β€” cycle length of Fibonacci numbers mod i

like. the length of the repeating cycle of Fibonacci numbers when you take them modulo i. that's the whole vibe. πŸŒ€


✨ SYNOPSIS ✨

use Math::NumSeq::PisanoPeriod;
my $seq = Math::NumSeq::PisanoPeriod->new;
my ($i, $value) = $seq->next;

that's it. that's the whole setup. load her, build her, call next and get a pair back. slay. πŸŽ€


✨ DESCRIPTION ✨

so this one is the length of the cycle of Fibonacci numbers modulo i. like, how many steps until the whole thing loops back around to where it started. obsessed.

1, 3, 8, 6, 20, 24, 16, 12, 24, 60, 10, 24, 28, 48, 40, ...
starting i=1

and the little example that makes it click: Fibonacci numbers modulo 4 repeat in a cycle of 6 numbers, so value=6. periodt.

Fibonacci  0, 1, 1, 2, 3, 5, 8,13,21,34,55,89,144,...
mod 4      0, 1, 1, 2, 3, 1, 0, 1, 1, 2, 3, 1, 0,...
           \--------------/  \--------------/  \---
         repeating cycle of 6

okay now here's the why, and it's lowkey gorgeous. the Fibonaccis are determined by a pair F[i],F[i+1], and there can be at most i*i many different pairs mod i. so there's always a finite repeating period β€” she can't run off forever, bestie, the pigeonhole principle said no. πŸ•ŠοΈ

and because the Fibonaccis can go backwards as F[i-1]=F[i+1]-F[i], the modulo sequence is purely periodic. which means the initial 0,1 is always part of the cycle. no awkward pre-roll, no intro that doesn't come back. just pure loop. iconic. πŸ”


✨ FUNCTIONS ✨

check out "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all the sequence classes β€” that's the shared girlies' stuff, this page is just her special features. πŸ’…

  • "$seq = Math::NumSeq::PisanoPeriod->new ()" β€” create and return a brand new sequence object. fresh out the box, no notes. 🎁

🌸 Random Access 🌸

  • "$value = $seq->ith($i)" β€” return the Pisano period of $i. like, just give me the value at index i, no scrolling required. so convenient of her. ✨

✨ SEE ALSO ✨

  • Math::NumSeq
  • Math::NumSeq::Fibonacci
  • Math::NumSeq::FibonacciWord

the whole friend group fr fr 🫢


✨ HOME PAGE ✨

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

go say hi. she lives there. 🏠


✨ LICENSE ✨

Copyright 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde

Math-NumSeq 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-NumSeq 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-NumSeq. If not, see <http://www.gnu.org/licenses/>.

ok so real talk: that "WITHOUT ANY WARRANTY" bit is not a joke, bestie. no promises of merchantability, no promises of fitness for a particular purpose. read the full GPL for the actual deets. πŸ™ˆ

and that's the page!! this was perl v5.42.0, dated 2025-07-25, and yeah the footer is literally Math::N...oPeriod(3) again bc the manpage header and footer are matching besties. ate and left no crumbs. bye love u πŸ’–πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from