Skip to content

Instantly share code, notes, and snippets.

View erik-t-irgens's full-sized avatar

Erik Irgens erik-t-irgens

View GitHub Profile
@erik-t-irgens
erik-t-irgens / Fibonacci.js
Created June 22, 2021 16:12
Finding the nth fibonacci number iteratively, recursively, and a combination of the two
// This function uses an array that is filled with the fibonacci sequence up to the provided digit, then returns the last result. This is known as iterative.
getNthFib = (n) => {
let fibArray = [0, 1]
if (n < 3) {
return fibArray[n - 1]
} else {
for (let i = 2; i < n; i++) {
fibArray.push(fibArray[i - 2] + fibArray[i - 1])
}
return fibArray[n - 1]

Keybase proof

I hereby claim:

  • I am erik-t-irgens on github.
  • I am sareth740 (https://keybase.io/sareth740) on keybase.
  • I have a public key ASCxTrVOZYbwlMozrYo-Yx91oiUXiXzs2UgOJmhtcUiZcgo

To claim this, I am signing this object: