Skip to content

Instantly share code, notes, and snippets.

@koji
Created May 18, 2020 21:57
Show Gist options
  • Save koji/a593df6b17f325204bea3b50748cb476 to your computer and use it in GitHub Desktop.
Save koji/a593df6b17f325204bea3b50748cb476 to your computer and use it in GitHub Desktop.
const fibonacci = n =>
  Array.from({ length: n }).reduce(
    (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
    []
  );

fibonacci(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment