/**
* Created by wangchaomac on 2017/3/13.
*/
/*
1.斐波那契数列
**/
function fbnq(sqIndex){
var firstNo = 1;
var secondNo = 1;
if( sqIndex < 2 ) {
if( sqIndex < 0) {
return 'error input param';
}
return 1;
}
var fbnqNo = -1;
for(var fbnqIndex = 2; fbnqIndex < sqIndex ; fbnqIndex ++) {
fbnqNo = firstNo + secondNo ;
firstNo = secondNo ;
secondNo = fbnqNo ;
}
return fbnqNo;
}
alert(fbnq(4));