public class StaticDemo
{
public static void main(String[] args)
{
for (int i = 3; i < 15; i++)
{
System.out.print("Fib( " + i + " )=" );
System.out.println(Fibonacci.next());
}
}
}
public class Fibonacci
{
private static int i=1;
private static int j=1;
private static int k;
public static int next()
{
k = i + j;
j = k;
i = j;
return k;
}
}
沒有留言:
張貼留言