Javascript Tutorial - fibonacci sequence with For statement

preview_player
Показать описание
__________________
Thank you for watching this video, if you like it please don't forget to like it,
or subscribe to my channel for more programming tutorials
---
also visit my website for more content
Рекомендации по теме
Комментарии
Автор

Isn't 0 considered fibonacci number? If you replace a=0 to a=1 and b=1 to b=0 it will print all numbers from 0.

var a, b, result;
a = 1;
b = 0;
result = b;
for (var i=1; i<=20; i++) {

result = a + b;
a = b;
b = result;
}

MrShades
Автор

There is a interesting vercion. Thanks🎉

AmirLT-xy
Автор

Somehow this video still useful in 2020. Thanks man

alunethx
Автор

Wow! The video is very satisfying and well explained

AMINULISLAM-zxmg
Автор

I feel like my version is a bit better(and simpler).
<script>
var a= 0;
var b = 1;
var c= 0;
while(c <= 121565){

document.write(c);
document.write("<br/>");
c = a + b;
a = b;
b =c;




}

</script>

thegameguy
Автор

For the ones who liked the editor, it's Sublime Text.

JOKBO
Автор

Try with this very simple and results will display in horizontal...I modified above betacoding
var fibonacci_series = function (n)
{
var a=0, b=1, f=b, s =[0, 1];
for(var i=0;i<n;i++) {
f= a+b;
s.push(f);
a=b;
b=f;
}
return s;
};
fibonacci_series(n)

jagadeeshak
Автор

Can someone explain to me why I can't get my numbers vertical instead of horizontal

freekodakblack
Автор

Not working :
if you ask for results over a 100, numbers start showing incorrectly.
if you ask for result over 1478, numbers are replaced by the word "infinity".

… No use, but nice try though !

pudupul
Автор

OMG!!

You're cheating dude!!
what?? i do not satisfy the function

saltech
welcome to shbcf.ru