Create Integer Array

Generate integer arrays - sequential, random, arithmetic, geometric, Fibonacci, primes (Sieve), or custom pattern. 5 output formats. Free, client-side.

Generate integer arrays with 7 modes - sequential, random (with/without duplicates), arithmetic, geometric, Fibonacci, primes (Sieve of Eratosthenes for large counts), or custom pattern. 5 output formats.

How to Use Create Integer Array

  1. Pick a mode. Sequential for a range. Random for sampling. Arithmetic/Geometric for progressions. Fibonacci/Primes for classic sequences. Custom for any repeating list.
  2. Fill mode-specific parameters. Sequential with start > end auto-counts down. Geometric with ratio = 1 produces a constant sequence (no error).
  3. (Optional) sort ascending / descending; (optional) reverse after sort.
  4. Pick output format. Newline for paste-into-spreadsheet. JSON for code. Bracket [1 2 3] for Python/MATLAB-style.
  5. Generate (or Ctrl+Enter). Stats line shows count, min, max, sum, mean, median, mode, unique count.
  6. Copy or download - extension auto-matches format (.txt or .json).

Frequently Asked Questions

How is the prime generator implemented?

For ≤ 1000 primes: trial division (check candidate against all primes up to √candidate). For > 1000 primes: Sieve of Eratosthenes. The Sieve estimates an upper bound via the prime number theorem (nth prime ≈ n · ln(n) for n > 6, with a 20% safety buffer), allocates a Uint8Array of that size, and marks composites in O(N log log N). Generating 10,000 primes via Sieve takes < 50 ms; via trial division takes ~10× longer.

What happens with geometric overflow?

JavaScript’s safe integer range tops out at 2^53 – 1 ≈ 9 quadrillion. Geometric progressions with ratio ≥ 2 reach this in 53 terms or fewer. The tool detects overflow before pushing Infinity – it stops at the last safe term and shows an info toast with the count returned.

Why is ratio = 1 allowed in geometric mode?

A geometric sequence with ratio 1 produces a constant sequence (start, start, start, …). Now allowed.

Why is Fibonacci capped at 100?

F(78) is already 8.9 trillion – past F(78) the values exceed JavaScript’s Number precision (53-bit mantissa). F(100) is 354 quadrillion, well past MAX_SAFE_INTEGER (9 quadrillion). For larger Fibonacci, use BigInt in your own script.

Why does sequential mode auto-reverse for start > end?

Now produces [10, 9, 8, …, 1]. Use arithmetic mode with negative step if you want a different step.

What does “unique” mean in the stats?

The number of distinct values in the array. If unique < count, the array contains duplicates. Useful for verifying random-without-duplicates mode and for spotting custom-pattern repetition.

What’s “mode” in the stats?

The most frequent value. If there’s a tie, the first-encountered tied value wins. Only shown when modeCount > 1 (i.e., at least one value appears more than once).

How fast is random sampling without duplicates for huge ranges?

Uses partial Fisher-Yates: builds the pool of size range, then runs count swap-steps. So memory is O(range) and time is O(count). For range = 1,000,000 and count = 1000, that’s 1 MB of memory and 1000 swaps – instant. The cap on total items is 1,000,000.

What separators does custom pattern accept?

Commas, semicolons, spaces, or any whitespace. Non-integer tokens are silently dropped. “1, 2; 3 -4” parses to [1, 2, 3, -4].

Is anything uploaded?

No. Pure browser-side generation. Random uses Math.random() (not cryptographically secure – for cryptographic use, use crypto.getRandomValues in your own code).