Fibonacci (original) (raw)
Published on 02 October 2018 (Updated: 24 May 2025)
Welcome to the Fibonacci page! Here, you'll find a description of the project as well as a list of sample programs written in various languages.
This article was written by:
- Jeremy Grifski
Description
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
Requirements
For this sample program, each solution should leverage dynamic programming to produce this list up to the nth term. For instance, ./fib 5
on the command line should output
In addition, there should be some error handling for situations where the user doesn't supply any input or the user supplies input that is not a number (i.e. ./fib
or ./fib hello
, respectively).
Testing
Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Fibonacci. In order to keep things simple, we split up the testing as follows:
- Fibonacci Valid Tests
- Fibonacci Invalid Tests
Fibonacci Valid Tests
Description | Input | Output |
---|---|---|
Sample Input 0 | "0" | |
Sample Input 1 | "1" | "1: 1" |
Sample Input 2 | "2" | "1: 1""2: 1" |
Sample Input 5 | "5" | "1: 1""2: 1""3: 2""4: 3""5: 5" |
Sample Input 10 | "10" | "1: 1""2: 1""3: 2""4: 3""5: 5""6: 8""7: 13""8: 21""9: 34""10: 55" |
Fibonacci Invalid Tests
Description | Input |
---|---|
No Input | |
Empty Input | "" |
Invalid Input: Not A Number | "a" |
All of these tests should output the following:
Usage: please input the count of fibonacci numbers to output
Articles
There are 39 articles:
- Fibonacci in Algol68
- Fibonacci in Awk
- Fibonacci in Bash
- Fibonacci in Beef
- Fibonacci in Boo
- Fibonacci in C
- Fibonacci in C#
- Fibonacci in C++
- Fibonacci in Commodore Basic
- Fibonacci in Dart
- Fibonacci in Elvish
- Fibonacci in Euphoria
- Fibonacci in Fortran
- Fibonacci in Go
- Fibonacci in Groovy
- Fibonacci in Haskell
- Fibonacci in Java
- Fibonacci in Javascript
- Fibonacci in Julia
- Fibonacci in Kotlin
- Fibonacci in Lisp
- Fibonacci in Lua
- Fibonacci in Mathematica
- Fibonacci in Moonscript
- Fibonacci in Nim
- Fibonacci in Objective C
- Fibonacci in Octave
- Fibonacci in Pascal
- Fibonacci in Perl
- Fibonacci in Php
- Fibonacci in Powershell
- Fibonacci in Python
- Fibonacci in Racket
- Fibonacci in Ruby
- Fibonacci in Rust
- Fibonacci in Scala
- Fibonacci in Swift
- Fibonacci in Ti Basic
- Fibonacci in Typescript