简体   繁体   English

斐波那契数列“显示数学数列”

[英]Fibonacci Sequence “Show the mathematical sequence”

Right now all I got is it generating the fib sequence I want to show the mathematical sequence after the result. 现在,我所得到的只是它生成的fib序列,我想在结果后显示数学序列。 ex. 恩。 8+13 = 21 8 + 13 = 21

How can I achieve this? 我该如何实现?

HTML : HTML

<div id="genhere"></div>

JavaScript/JQuery : JavaScript / jQuery

$(document).ready(function() {
    console.log = function(message) {
        $('#genhere').append('<p>' + message + '</p>');
    };

    console.error = console.debug = console.info = console.log;

    var fib = function(numMax) {
        for(a=0, b=1, c=0; c<numMax; a=b, b=x, c++){
            x=a+b;
            console.log(x);
        }
    };

    fib(50);
});
console.log(a + ' + ' + b + ' = ' + x);

这是小提琴: http : //jsfiddle.net/9Kagz/

如果我已正确理解,您是要打印类似内容吗?

console.log(a+"+"+b+"="+x);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM