Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test

Home » JavaScript code to print Febonacci Series

JavaScript code to print Febonacci Series


<script>
var a = 1;
var b = 2;

document.write(a + " ");
document.write(b + " ");

for (var line=1; line<15; line++) {
        var temp = a;
        a = b;
        b = temp + b;
        document.write(b + " ");
}
</script>