斐波那契额数列 1 1 2 3 5 8 ,输出完整数列,并输出第n项
var first=1,second=1,third;
var arr = [];
if(n>2){
for(var i = 0;i < n - 2;i++){
if(first == 1 && second==1){
arr.push(first,second);
}else{
arr.push(third);
}
third = first + second;
first = second;
second = third;
}
arr.push(third);
document.write(third + "<br/>");
document.write(arr);
}else{
document.write(1);
}