aboutsummaryrefslogtreecommitdiff
path: root/entries/kekerr/fib.ts
blob: cc42fcfdd5b4fc2f87c753b183d34d015b1c5bbf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function fibonacci(n: number): string {
	if (n <= 0) {
		return "Surely that's a mistake! We can't give you anything interesting!";
	}

	if (n == 1) {
		return "This one's easy: [1]";
	}

	const seq = [1, 1];
	for(let i = 2; i < n; i++) {
		seq.push(seq[i-1] + seq[i-2]);
	}

	return "Fibonacci this: " + seq.toString();
}