fixed gulpfile
[tech-radar.git] / src / util / fib.js
1 tr.util.Fib = function () {
2 var self = {};
3
4 self.sequence = function (length) {
5 var result = [0, 1];
6
7 for (var i = 2; i < length; i++) {
8 result[i] = result[i-2] + result[i-1];
9 }
10
11 return result;
12 };
13
14 self.sum = function (length) {
15 if (length === 0) { return 0; }
16 if (length === 1) { return 1; }
17
18 return self.sequence(length + 1).reduce(function (previous, current) {
19 return previous + current;
20 }, 0);
21 };
22
23 return self;
24 };