public
class
Fibonacci {
private static int MAX = 100 ;
/*
* print the Fibonacci sequence for values < MAX
*/
public static void main(String[] args) {
int currentVal = 1 ;
int nextVal = 1 ;
while (currentVal < MAX){
System.out.println(currentVal);
nextVal = nextVal + currentVal ;
currentVal = nextVal - currentVal;
}
}
}
private static int MAX = 100 ;
/*
* print the Fibonacci sequence for values < MAX
*/
public static void main(String[] args) {
int currentVal = 1 ;
int nextVal = 1 ;
while (currentVal < MAX){
System.out.println(currentVal);
nextVal = nextVal + currentVal ;
currentVal = nextVal - currentVal;
}
}
}
本文转自BlogJavaOo缘来是你oO的博客,原文链接:Print Fibonacci Sequcnce,如需转载请自行联系原博主。