Pisano Period Calculator

Explore Pisano periods and Fibonacci cycles effortlessly. Analyze modular arithmetic patterns with detailed visual results. Unlock the hidden rhythm of number sequences today.

Calculator

Any integer ≥ 2.
Up to 40 digits. Matrix exponentiation.

Example Reference Table

mπ(m)α(m)π/mπ even?Notes
231 1.5 No Smallest
384 2.667 Yes π=2(m+1)
463 1.5 Yes
5205 4 Yes π=4m
62412 4 Yes lcm(π2,π3)
7168 2.286 Yes Prime
8126 1.5 Yes
92412 2.667 Yes
10605 6 Yes Last digit
111010 0.909 Yes π=m−1
122412 2 Yes Composite
1377 0.538 No Prime
14487 3.429 Yes Composite
15405 2.667 Yes lcm(π3,π5)
162412 1.5 Yes 2⁴
17369 2.118 Yes Prime
182412 1.333 Yes 2·3²
191818 0.947 Yes Prime
20605 3 Yes 4·5
10030025 3 Yes 10²

Formulas & Mathematical Background

Definition

π(m) = smallest positive k such that F(k) ≡ 0 (mod m) AND F(k+1) ≡ 1 (mod m).

Rank of Apparition α(m)

α(m) = smallest k > 0 with F(k) ≡ 0 (mod m). It always divides π(m). For prime p, α(p) divides p−1 or 2(p+1) depending on the Legendre symbol (5|p).

Key Properties

Matrix Exponentiation

[ F(n+1) ]   [ 1 1 ]^n   [ 1 ]
[ F(n)   ] = [ 1 0 ]   * [ 0 ]  (mod m)

Step 1: reduce n to n mod pi(m)
Step 2: matrix power via repeated squaring O(log n)

Wall–Sun–Sun Conjecture

No prime p is known satisfying p² | F(p − (5|p)). The Legendre symbol (5|p) = +1 if p ≡ ±1 (mod 5), −1 if p ≡ ±2 (mod 5), 0 if p = 5.

Lucas Sequence Mod m

The Lucas sequence L(n) satisfies the same recurrence F(n+2) = F(n+1) + F(n) but starts at L(0) = 2, L(1) = 1. Its period modulo m also equals π(m), sharing the same Pisano period as Fibonacci.

How to Use This Calculator

  1. Single Modulus: Enter any m ≥ 2. Optionally enter a huge n to compute F(n) mod m instantly. Toggle residue frequency and heatmap charts. Choose how many periods to plot.
  2. Range: Set start and end (up to 500). Generates a bar chart of π(m), an overlay of α(m), a ratio line, and a sortable table with prime flags. Download as CSV.
  3. F(n) mod m: Enter n up to 40 digits and any m. The calculator first reduces n modulo π(m), then applies 2×2 matrix exponentiation in O(log n) time.
  4. Multiplicativity Verifier: Enter two coprime integers a and b. Confirms π(a·b) = lcm(π(a), π(b)).
  5. LCM of Periods: Provide a comma-separated list of moduli. Computes each π(m) and returns their combined LCM.
  6. Wall–Sun–Sun: Enter primes to test the unsolved conjecture. All known results return "No".
  7. Fibonacci vs Lucas: Side-by-side chart and table comparing F(i) mod m and L(i) mod m over one Pisano period.
  8. Downloads: CSV includes metadata and the full sequence. JSON is structured with all computed fields. PDF opens a printable report. "Copy Summary" puts key stats on your clipboard.

Understanding the Pisano Period in Number Theory

What Is the Pisano Period?

The Fibonacci sequence is infinite. When you compute it modulo any fixed integer m, the result is finite and periodic. This period is called the Pisano period, denoted π(m). It is named after Leonardo Pisano, better known as Fibonacci. Modulo 5, the sequence 0,1,1,2,3,0,3,3,1,4,0,4,4,3,2,0,2,2,4,1 restarts after 20 terms, so π(5) = 20.

The Rank of Apparition

Every modulus m has a rank of apparition α(m): the smallest positive index k at which F(k) ≡ 0 (mod m). It always divides π(m). For example, α(5) = 5 and π(5) = 20. The rank plays a key role in Fibonacci divisibility theory and in testing Fibonacci pseudoprimes.

Why Does the Sequence Repeat?

The Fibonacci recurrence depends only on the two previous terms. Modulo m, each term lies in {0, …, m−1}. There are only m² possible consecutive pairs. By the Pigeonhole Principle, some pair must eventually repeat. Once (0, 1) reappears, the entire sequence restarts from the beginning.

Historical Context

Édouard Lucas studied Fibonacci residues in the 1870s. Donald Wall published the first systematic theory in 1960. Wall conjectured that no prime p satisfies p² | F(p − (p/5)). This remains unproven. Computational searches have verified it for all primes up to approximately 3×1017.

Pisano Periods and Prime Numbers

For a prime p, π(p) divides either p−1 or 2(p+1). Which one depends on p modulo 5. If p ≡ ±1 (mod 5), then π(p) | (p−1). If p ≡ ±2 (mod 5), then π(p) | 2(p+1). These rules come from quadratic reciprocity and the factorization of the polynomial x²−x−1 over 𝔽_p.

Multiplicative Structure

If gcd(a, b) = 1, then π(a·b) = lcm(π(a), π(b)). Decompose any composite m into coprime prime-power components, compute each period, and combine via LCM. For m = 10 = 2×5: lcm(π(2), π(5)) = lcm(3, 20) = 60 = π(10). This dramatically reduces computation for large m.

Matrix Exponentiation and Large Fibonacci Numbers

Computing F(n) mod m for n = 1018 by iteration is impossible in practice. Instead, reduce n to n mod π(m), then apply 2×2 matrix exponentiation. The result arrives in O(log n) multiplications. This technique is essential in competitive programming, where n can exceed 1018.

Fibonacci vs Lucas Sequences

The Lucas sequence L(n) satisfies the same recurrence as Fibonacci but starts at L(0)=2, L(1)=1. Both share the same Pisano period π(m) because the period depends only on the recurrence relation, not the initial values. The two sequences are connected: L(n) = F(n−1) + F(n+1). Comparing them modulo m reveals complementary residue patterns.

Visualizing the Patterns

Plotted sequences modulo m display striking symmetry. For prime m, F(π−k) + F(k) = m, creating a palindromic structure. The heatmap view reveals zero clusters and residue gaps at a glance. Residue frequency charts confirm that each value appears nearly uniformly across the period.

Frequently Asked Questions

1. What is the Pisano period?

π(m) is the length of the repeating cycle of Fibonacci numbers modulo m. After π(m) steps the sequence returns to (0,1) and restarts. It exists for every positive integer m and is always finite.

2. Why is π(10) = 60?

Since 10 = 2×5 and gcd(2,5)=1, multiplicativity gives π(10) = lcm(π(2), π(5)) = lcm(3, 20) = 60. This explains why the last digit of Fibonacci numbers repeats every 60 terms exactly.

3. What is the rank of apparition?

α(m) is the smallest positive k with F(k) ≡ 0 (mod m). It always divides π(m). For prime p, α(p) equals the first Fibonacci index divisible by p. It is foundational to Fibonacci divisibility theory.

4. How is F(n) mod m computed for huge n?

First reduce n to n mod π(m). Then apply 2×2 matrix exponentiation. This gives the answer in O(log n) time, making billion-digit indices tractable within milliseconds on any modern server.

5. What is the Wall–Sun–Sun conjecture?

It conjectures no prime p satisfies p² | F(p−(5|p)). Verified computationally up to ~3×1017 but unproven. Finding a counterexample would be one of the most significant discoveries in modern number theory.

6. Is the Pisano period always even?

Not always. π(2) = 3, which is odd. For all m ≥ 3, the period is even. This follows from the antisymmetric structure of the second half of each Fibonacci period modulo m.

7. How does the Lucas sequence relate to Fibonacci?

Both satisfy the same recurrence but differ in starting values: F(0)=0, F(1)=1 vs L(0)=2, L(1)=1. They share the same Pisano period π(m). The identity L(n) = F(n−1)+F(n+1) links them algebraically.

8. How does Pisano period relate to the golden ratio?

φ = (1+√5)/2 satisfies φ² = φ+1. The Pisano period reflects how φ behaves in 𝔽_p. When p splits in ℤ[φ], π(p) | (p−1); when p is inert, π(p) | 2(p+1).

Related Calculators

Modular Exponentiation Fast Power CalculatorReverse Euclidean algorithm calculatorfast modular exponentiation calculatorLarge number modulo calculatormodular congruence solvereuler totient calculatorprime number checkerextended euclidean calculatormodular inverse calculatorlegendre symbol calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.