Pisano period calculator
Find the Pisano period for any modulus up to 1,000,000: modulo 10 the Fibonacci remainders repeat every 60 steps, and modulo 2 every 3. The answer is the exact cycle length, worked out with whole numbers only. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- M
- 10
- Pisano period
- 60
The Pisano period calculator finds how many Fibonacci residues occur before the sequence repeats for a chosen positive modulus. Instead of producing an arbitrary number of Fibonacci terms, it follows consecutive residue pairs until the unique starting state returns, then reports that cycle length. This is useful in modular arithmetic, programming contests, recurrence analysis, and algorithms that need large Fibonacci indices reduced safely. Enter a modulus from 1 through 1,000,000 to receive an exact, deterministic result.
What a Pisano period measures
The Fibonacci sequence begins 0, 1, 1, 2, 3, 5, and continues by adding the previous two terms. Taking every term modulo m replaces each Fibonacci number with its remainder after division by m. Because only finitely many ordered pairs of remainders are possible, this derived sequence eventually repeats.
For Fibonacci residues, repetition returns to the starting pair, so the number of steps before that return is called the Pisano period. For example, modulo 2 the residues are 0, 1, 1 and then the pattern starts again, giving a period of 3. Modulo 10 has period 60, which explains why the last digits of Fibonacci numbers repeat every 60 positions.
This calculator returns the cycle length itself, not a list of residues and not a Fibonacci term. The special modulus 1 has only the residue 0, so its one-state sequence has period 1. Every supported calculation uses exact integer arithmetic; no approximation, sampling, or probabilistic test is involved.
How the calculator detects the cycle
A Fibonacci value depends on the two values immediately before it, so a single repeated remainder is not enough to prove that the whole sequence has restarted. The calculator therefore tracks an ordered pair of consecutive residues. It starts with 0 and 1, repeatedly replaces the pair with the next modular Fibonacci pair, and counts each transition.
When the ordered pair 0, 1 appears again, the count is the Pisano period. This pair-based test avoids false stops that could happen if the implementation watched only for a zero or for any repeated individual remainder. Memory use remains constant because the calculation needs only the current pair and a counter; it does not store the entire cycle.
The modulus is capped at 1,000,000 so runtime is explicitly bounded for an interactive request. Inputs must be whole positive integers. Decimal fractions, nonnumeric strings, zero, negative values, and values above the published limit are rejected rather than rounded or silently changed.
Using the result in modular Fibonacci work
Once the period p is known, Fibonacci indices can be reduced modulo p whenever only the value modulo m matters: F(n) mod m equals F(n mod p) mod m. That identity turns an enormous index into a much smaller equivalent index before a fast-doubling or matrix-exponentiation calculation. It is especially helpful when an index is supplied as a very long decimal string, when a recurrence appears inside a cryptographic exercise, or when a programming problem asks only for trailing digits.
Keep the roles of the two moduli separate: m controls the Fibonacci remainders, while the returned Pisano period controls index reduction. A period is not generally equal to m, and periods for composite moduli reflect the interaction of their prime-power factors. There is no per-term charge, and the algorithm makes no network calls or use of external data.
What you can do with it
Reduce a huge Fibonacci index
Find the cycle length first, reduce the index by that period, and compute only the equivalent modular Fibonacci position.
Check repeating final digits
Use modulus 10, 100, or another power of ten to determine how often the last digits of Fibonacci numbers repeat.
Verify number-theory exercises
Confirm expected modular cycle lengths while studying recurrences, congruences, prime powers, or composite moduli.
FAQ
What is a Pisano period?
It is the number of Fibonacci residues modulo m before the ordered sequence returns to its starting state and repeats.
Why is the Pisano period for modulus 1 equal to 1?
Modulo 1, every integer has residue 0, so the residue sequence consists of one repeating state.
Does the result give a Fibonacci number?
No. It gives the length of the repeating Fibonacci residue cycle for the requested modulus.
Why do the last digits of Fibonacci numbers repeat?
The last digit is the remainder after dividing by 10, and modulo 10 the Pisano period is 60. So the last digits of the Fibonacci numbers start over every 60 positions.
How does the Pisano period help with a huge Fibonacci index?
If you only need the remainder modulo m, shrink the index first: F(n) mod m equals F(n mod p) mod m, where p is the period. Modulo 10, you only need the index modulo 60.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/numth/pisano-period \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"m":10}'const res = await fetch("https://api.kit.forhosting.com/numth/pisano-period", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"m": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/pisano-period",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"m": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/pisano-period", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"m":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"m":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/pisano-period", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"m": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.pisano_period",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_m | 1000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
How the calculator detects the cycle
The same deterministic core is used for browser and API execution.
Using the result in modular Fibonacci work
For reproducible workflows, store both the submitted m and the returned pisano_period; the response includes both fields for that reason. A request is priced at $0.002.
Technical questions
Can I enter zero or a negative modulus?
No. A modulus below 1 is invalid and returns an invalid_input error.
What is the largest supported modulus?
The calculator accepts positive integer moduli up to 1,000,000 so each request has a clear execution bound.
What does an API request cost?
Each request costs $0.002. The calculation has no variable per-term fee.