Back
Close

Fibonacci 2

Statement

 Goal

A Fibonacci sequence of order n is an integer sequence in which each element is the sum of the previous n elements, except for the first n elements which are {0, 0, 0, ... 0, 1}.
Meaning:
If order is 3, then the sequence will be:
0, 0, 1, 1, 2, 4, 7, 13, 24, ...

Output the first numbers numbers of the Fibonacci sequence of order order.

Example:
If numbers is 7 and order is 4, output:
0, 0, 0, 1, 1, 2, 4
Input
Line 1: An integer numbers for the amount of numbers
Line 2: An integer order for the number of previous numbers you need to calculate the sum of.
Output
The first numbers of the different Fibonacci.
Constraints
3 ≤ numbers ≤ 15
1 ≤ order ≤ 10
Example
Input
7
4
Output
0, 0, 0, 1, 1, 2, 4

Game modes
FastestShortest

Test cases
Example Test
Input
7 4
Output
0, 0, 0, 1, 1, 2, 4

Validator 1 Validator
Input
7 3
Output
0, 0, 1, 1, 2, 4, 7

Original Fibonacci Test
Input
5 2
Output
0, 1, 1, 2, 3

Validator 2 Validator
Input
6 2
Output
0, 1, 1, 2, 3, 5

1, 1, 1, 1, 1, 1, 1 Test
Input
7 1
Output
1, 1, 1, 1, 1, 1, 1

Validator 3 Validator
Input
5 1
Output
1, 1, 1, 1, 1

BIG order Test
Input
15 7
Output
0, 0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 64, 127

Validator 4 Validator
Input
15 6
Output
0, 0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 32, 63, 125, 248

Solution language

Solution

Stub generator input
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants