Guest User

Untitled

a guest
Feb 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. const fibo = (num) => {
  2. const seq = [0, 1];
  3.  
  4. if (num <=2) {
  5. return 1;
  6. }
  7.  
  8. for (let i = 2; i <= num; i++) {
  9. seq[i] = seq[i-1] + seq[i-2];
  10. }
  11.  
  12. return seq[num]
  13. }
  14.  
  15. console.log(fibo(12));
Add Comment
Please, Sign In to add comment