Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Arvin iuunhao
Added: Jun 18, 2018 8:25 AM
Views: 5
Tags: js
斐波纳契数组发生器
  1. const fibonacci = n =>
  2.   Array(n).fill(0).reduce((acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), []);
  3. // fibonacci(5) -> [0,1,1,2,3]