Number Sequence Generator
100% LocalGenerate Fibonacci, primes, factorials, Pascal's triangle, GCD and LCM.
Pick a sequence type (Fibonacci, primes, factorials). Set the count and starting values.
What is Number Sequence Generator?
Frequently Asked Questions
Technical Deep Dive
Number Sequence Generator
Six math tools in one: generate Fibonacci sequence up to 78 terms (BigInt), first N prime numbers (Sieve of Eratosthenes), factorial of N (arbitrary precision BigInt), Pascal's triangle up to 15 rows, prime number checker for any integer, and GCD/LCM calculator.
Built for Devs
Designed by people who use these tools in production every day.
Smart Defaults
Reasonable assumptions out of the box, every assumption overridable when you need it.
Workflow-Friendly
Pairs with your IDE, CI, and code review, output drops into commits and PRs cleanly.
The Six Sequences You'll Compute Again and Again
If you've taken a programming course, prepped for a coding interview, or done late-night recreational math, you've computed each of these by hand at least once. They show up in textbook exercises, LeetCode warmups, project Euler problems, and the dreaded "implement Fibonacci on a whiteboard" interview question. This generator runs the standard algorithms with the right precision so you can check your work or just get the answer.
Fibonacci
The sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Each number is the sum of the previous two. Defined by Fibonacci (Leonardo of Pisa) in 1202 to model rabbit populations.
Why it appears everywhere:
- Mathematical analysis. The ratio F(n+1)/F(n) approaches the golden ratio φ ≈ 1.618. Connection to continued fractions, Lucas numbers, Zeckendorf's theorem.
- Algorithm complexity. Recursive naive Fibonacci is the canonical example of exponential complexity, O(2^n), and the canonical example for memoization (O(n) with caching).
- Coding interviews. "Compute Fibonacci" tests recursion, iteration, memoization, and (for the senior version) matrix exponentiation for O(log n).
- Biology. Sunflower seed arrangements, pine cone scales, spiral phyllotaxis all approximate Fibonacci.
The generator uses iteration with BigInt for exact precision. Up to F(78) = 8,944,394,323,791,464 fits in a double; beyond that you need BigInt.
Primes via Sieve of Eratosthenes
The sieve dates to roughly 200 BC and remains the fastest practical algorithm for "find all primes below N" for moderate N.
The algorithm:
- Create a boolean array of size N+1, all true (except 0 and 1).
- Start at p=2. If p is true, it's prime, mark all multiples of p (2p, 3p, 4p, ...) as false.
- Increment p. Repeat until p > √N.
- Every remaining true index is prime.
Why it's fast: Most numbers get crossed out early. The number of operations is approximately N × (1/2 + 1/3 + 1/5 + 1/7 + ...) = N × ln(ln(N)) + O(N), astonishingly small.
Limits: Memory is O(N), so generating primes below 10^9 needs a gigabyte of bits. Beyond that, use a segmented sieve that processes ranges and discards them. For cryptography-scale primes (10^300), use probabilistic tests like Miller-Rabin.
This generator works comfortably for the first 10,000+ primes, covers most homework and contest needs.
Factorial with BigInt
n! = 1 × 2 × 3 × ... × n. Grows even faster than Fibonacci: 20! ≈ 2.4 × 10^18, just past Number.MAX_SAFE_INTEGER. 100! is 158 digits. 1000! is 2,568 digits.
Common uses:
- Combinatorics.
C(n, k) = n! / (k! (n-k)!)for choosing k from n. - Permutations. n! ways to arrange n distinct items.
- Probability. Many distributions have factorial terms.
- Mathematical analysis. Taylor series, Stirling's approximation.
Practical note: For very large factorials, Stirling's approximation n! ≈ √(2πn) × (n/e)^n is often more useful than the exact number, it gives you the digit count and a high-precision approximation without the actual giant integer.
Pascal's Triangle
Each entry is the sum of the two directly above:
Row n, column k is the binomial coefficient C(n, k) = n!/(k!(n-k)!). The triangle visualizes the entire family of binomial coefficients at once.
Patterns hiding in plain sight:
- Row sums: Row n sums to 2^n.
- Diagonals: First diagonal = constant (1). Second = natural numbers (1, 2, 3, ...). Third = triangular numbers (1, 3, 6, 10, ...). Fourth = tetrahedral.
- Mod 2: Color the odd entries, you get the Sierpinski triangle fractal.
- Fibonacci: Sum the entries along the "shallow diagonals" (right-to-left at slope -2) and you get Fibonacci numbers.
The generator displays up to 15 rows clearly; beyond that the formatting gets unwieldy.
Primality Testing
Is N prime? For "moderate" N (up to ~10^15), trial division is fine:
O(√n) time. For n = 10^15, that's ~30 million operations, milliseconds.
For larger n (cryptographic primes, 100+ digits), use Miller-Rabin (probabilistic, very fast, vanishingly small error rate with enough rounds) or AKS (deterministic polynomial-time but slower in practice). The OpenSSL command openssl prime handles this; so do most number-theory libraries.
GCD and LCM via Euclidean Algorithm
GCD via Euclid's algorithm (the oldest algorithm in continuous practical use, ~300 BC):
O(log(min(a, b))) iterations. Faster than any modern alternative for the integers you'll encounter.
LCM derives directly: lcm(a, b) = a × b / gcd(a, b). The division is exact.
Why this matters:
- Adding fractions.
1/12 + 1/18: LCM(12, 18) = 36, so 3/36 + 2/36 = 5/36. - Scheduling. Two events repeating every 12 and 18 days respectively coincide every LCM(12, 18) = 36 days.
- Cryptography. RSA key generation involves GCD checks (e is coprime to φ(n) iff gcd(e, φ(n)) = 1).
- Reducing fractions to lowest terms. Divide numerator and denominator by their GCD.
When to Move Past This Tool
For one-off lookups: this tool. For systematic exploration of integer sequences: the OEIS (Online Encyclopedia of Integer Sequences) at oeis.org, paste any sequence and it tells you what it is, its generating function, related sequences, and references.
For heavy computation: SymPy (Python), Mathematica, Wolfram Alpha (web), or PARI/GP. They handle billion-digit primes, symbolic manipulation, and the more exotic number-theory algorithms.
For competitive programming: a templated C++ solution with custom BigInt or a Python script. Browser tools have overhead these don't.
Privacy
All computation is pure JavaScript running locally. Inputs and outputs stay in your tab. Open DevTools Network during use: zero outbound requests.