import java.util.Scanner;
class Fibonacci {
public static int fibonacci(int n) {
if (n <= 0) {
return 0;
}
if (n == 1) {
return 1;
}
int f0 = 0;
int f1 = 1;
int fibo = 0;
for (int i = 0; i < n; i++) {
fibo = f0 + f1;
f0 = f1;
f1 = fibo;
}
return f0;
}
public static void main
(String[] args
) {
Scanner scanner
= new Scanner
(System.
in); System.
out.
print("Enter an integer n: "); int n = scanner.nextInt();
scanner.close();
System.
out.
println("Output: " + fibonacci
(n
)); }
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKICAgY2xhc3MgRmlib25hY2NpIHsKCiAgICBwdWJsaWMgc3RhdGljIGludCBmaWJvbmFjY2koaW50IG4pIHsKICAgICAgICAKICAgICAgICBpZiAobiA8PSAwKSB7CiAgICAgICAgICAgIHJldHVybiAwOyAKICAgICAgICB9CiAgICAgICAgaWYgKG4gPT0gMSkgewogICAgICAgICAgICByZXR1cm4gMTsgCiAgICAgICAgfQogICAgICAgIAogICAgICAgIGludCBmMCA9IDA7IAogICAgICAgIGludCBmMSA9IDE7IAogICAgICAgIGludCBmaWJvID0gMDsgCgogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgIGZpYm8gPSBmMCArIGYxOyAKICAgICAgICAgICAgZjAgPSBmMTsKICAgICAgICAgICAgZjEgPSBmaWJvOwogICAgICAgIH0KICAgICAgICAKICAgICAgICByZXR1cm4gZjA7CiAgICB9CgogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAKICAgICAgICBTY2FubmVyIHNjYW5uZXIgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIkVudGVyIGFuIGludGVnZXIgbjogIik7CiAgICAgICAgaW50IG4gPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICBzY2FubmVyLmNsb3NlKCk7CgoKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIk91dHB1dDogIiArIGZpYm9uYWNjaShuKSk7IAogICAgfQp9