Lab 12-12-2005 (2) Static Class
package lab;
public class Fibonacci {
public static double num0 = 1, num1 = 1, sum = 0;
public static double next() {
sum = num0 + num1;
num0 = num1;
num1 = sum;
return sum;
}
public static void main(String[] args) {
for (int i = 0; i < 50; i++) {
Fibonacci.next();
System.out.println("F(" + (i + 2) + ") = " + sum);
}
}
}
public class Fibonacci {
public static double num0 = 1, num1 = 1, sum = 0;
public static double next() {
sum = num0 + num1;
num0 = num1;
num1 = sum;
return sum;
}
public static void main(String[] args) {
for (int i = 0; i < 50; i++) {
Fibonacci.next();
System.out.println("F(" + (i + 2) + ") = " + sum);
}
}
}
0 Comments:
張貼留言
<< Home