Bootstrap

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

//费波纳列数列,前两位是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();
}

;