12/12lab(2)
public class fib {
public static double f0=1,f1=1,f2=0;
public static double next(){
f2=f0+f1;
f0 = f1;
f1 = f2;
return f2;
}
public static void main(String[] args) {
int i;
for(i=0;i<=100;++i){
System.out.println(i +"="+ f2);
fib.next();
}
}
}
0 Comments:
Post a Comment
<< Home