1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00

Add "fibonacci-suite" challenge

This commit is contained in:
Divlo 2020-07-05 18:29:17 +02:00
parent e1eb4f73ea
commit 59e0d5934d
5 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,12 @@
# fibonacci-suite
Created by [@Divlo](https://github.com/Divlo) at 5 July 2020.
## Instructions :
The function should return an array of fibonacci numbers. The function takes a `number` as an argument to decide how many number of elements to produce.
**Note :** The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Each subsequent number is the sum of the previous two.
## Examples :
See the `input-output.json` file for examples of input/output.

View File

@ -0,0 +1,6 @@
[
{
"input": [14],
"output": [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]
}
]

View File

@ -0,0 +1,4 @@
# typescript-recursive - fibonacci-suite
Programming language : TypeScript
Created by [@Divlo](https://github.com/Divlo) at 5 July 2020.

View File

@ -0,0 +1,8 @@
function solution (counter: number, result: number[] = [], number1: number = 0, number2: number = 1): number[] {
if (counter === 0) return result
counter--
result.push(number1)
return solution(counter, result, number2, number1 + number2)
}
export default solution