package
fibonacci;
import
java.io.*;
import
java.util.logging.Level;
import
java.util.logging.Logger;
public
class fibonacci_batasan_diinputkan {
public static void main(String[] args){
try {
BufferedReader input = new BufferedReader
(new InputStreamReader(System.in));
int a = 1;
int b = 2;
int c = 0;
int deret = 0;
System.out.println("Masukkan batasan
deret: ");
deret = Integer.parseInt(input.readLine());
System.out.print(a+ "," +b);
for(int x=0; x<deret; x++){
while (c<deret){
c = a + b;
a = b;
b = c;
if(c<deret){
System.out.print( "," +c);
}
}
}
} catch (IOException ex) {
Logger.getLogger(fibonacci_batasan_diinputkan.class.getName()).log(Level.SEVERE,
null, ex);
}
}
}
0 komentar:
Posting Komentar