idev0085 / react-boilerplate

0 stars 0 forks source link

Fibonacci series in JavaScript #101

Open idev0085 opened 2 years ago

idev0085 commented 2 years ago
function f(num){
  var n1 = 0,  n2 = 1, next_num, i;  
  for (i = 1; i <= num; i++){  
      console.log(n1)
      next_num = n1 + n2;
      n1 = n2;
      n2 = next_num;
  }  
}
f(10)

0 1 1 2 3 5 8 13 21 34