您的位置:首页 > 其它

费波纳列数列,不用递归的做法

2018-03-21 20:31 375 查看
//费波纳列数列,前两位是1,之后没位数是前两位数的和
private static void fibonacci(int n) {
int temp1=1,temp2=1,temp;
System.out.print(temp1+","+temp2);
for (int i = 1; i <=n ; i++) {
temp=temp1+temp2;
System.out.print(","+temp);
temp1=temp2;
temp2=temp;
}
System.out.println();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐