Generate a Fibonacci sequence

Generate a finite sequence beginning 0, 1, with each term equal to the previous two summed.

freeworks offlinenothing uploaded
ToolFibonacci Generator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The sequence starts with 0 and 1, then each next term is their sum. The requested count controls output length and iteration avoids a closed-form approximation.

  • Ten terms are the initial count.
  • Output is bounded to prevent unbounded growth.

Worked example

First 10 Fibonacci Numbers
Generate the first 10 numbers in the Fibonacci sequence
Input
											10
										
Output
												0, 1, 1, 2, 3, 5, 8, 13, 21, 34
											

When to use this

Programming lessons demonstrate recurrence, number theory inspects consecutive ratios, and puzzle generators produce finite sequences.

Edge cases

  • A count of zero returns no terms.
  • The sequence begins 0, 1 rather than 1, 1.
  • Large counts eventually exceed safe integer precision in JavaScript numbers.