Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function functionalFib(numOfElements) {
- function fib(a) {
- if (a === 0) {
- return 0;
- }
- if (a === 1) {
- return 1;
- }
- return fib(a - 1) + fib(a - 2);
- }
- function repeat(num, max, arr) {
- if (num > max) {
- return arr;
- }
- return repeat(num + 1, max, [].concat(arr, fib(num)))
- }
- return repeat(1, numOfElements, []);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement