7 kyu
Leonardo numbers
327 of 917___i
Description:
Leonardo numbers
The Leonardo numbers are a sequence of numbers defined by:
L(0) = 1 || 0
L(1) = 1 || 0
L(x) = L(x - 1) + L(x - 2) + 1
Generalizing the above a bit more:
L(x) = L(x - 1) + L(x - 2) + a
Assume a
to be the add number.
Task
Return the first n
Leonardo numbers as an array (vector<int>
in C++)
Input
n
: The number of Leonardo numbers to be shownL0
: The initial value of L(0)L1
: The initial value of L(1)add
: The add number
Examples
input : n = 5 , L0 = 1 , L1 = 1 , add = 1
output : [ 1, 1, 3, 5, 9 ]
input : n = 5 , L0 = 0 , L1 = 0 , add = 2
output : [ 0, 0, 2, 4, 8 ]
input : n = 10 , L0 = 0 , L1 = 1 , add = 4
output : [ 0, 1, 5, 10, 19, 33, 56, 93, 153, 250 ]
input : n = 5 , L0 = 0 , L1 = 0 , add = 0
output : [ 0, 0, 0, 0, 0 ]
Note
n
will always be greater than or equal to 2
Algorithms
Arrays
Similar Kata:
Stats:
Created | Jun 13, 2018 |
Published | Jun 13, 2018 |
Warriors Trained | 1634 |
Total Skips | 22 |
Total Code Submissions | 1917 |
Total Times Completed | 917 |
JavaScript Completions | 327 |
Python Completions | 395 |
Ruby Completions | 48 |
C++ Completions | 197 |
Groovy Completions | 18 |
CoffeeScript Completions | 7 |
Total Stars | 20 |
% of votes with a positive feedback rating | 87% of 207 |
Total "Very Satisfied" Votes | 166 |
Total "Somewhat Satisfied" Votes | 28 |
Total "Not Satisfied" Votes | 13 |
Total Rank Assessments | 6 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |