mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
22 lines
296 B
Java
22 lines
296 B
Java
import java.util.Scanner;
|
|
|
|
public class FibToN {
|
|
|
|
public static void main(String[] args) {
|
|
Scanner scn = new Scanner(System.in);
|
|
|
|
int n = scn.nextInt();
|
|
|
|
int fn = 0, sn = 1;
|
|
|
|
while(fn <= n){
|
|
System.out.println(fn);
|
|
|
|
int next = fn + sn;
|
|
fn = sn;
|
|
sn = next;
|
|
}
|
|
}
|
|
|
|
}
|