Homework 3-20-2006
import java.io.BufferedReader;import java.io.InputStreamReader;
import java.io.IOException;
public class Fibonacci
{
public static void main(String[] args) throws IOException
{
int i;
double f0 = 0, f1 = 1, f2 = 0, ratio = 0;
for (i = 1; i <= 100; i++)
{
f2 = f0 + f1;
ratio = f2 / f1;
f0 = f1;
f1 = f2;
System.out.println(i+"\t"+f2+"\t"+" ratio is "+ratio);
}
}
}
0 Comments:
Post a Comment
<< Home