Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static int getFibonacci(int n) {
- if (n == 1 || n == 2) {
- return 1;
- }
- return getFibonacci(n - 1) + getFibonacci(n - 2);
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- System.out.print(getFibonacci(n));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement