반응형
    
    
    
  
	// Recursive method for getting the fibonacci number for N
	public static int Fibonacci(int N) {
		if(N == 0) return 0;
		if(N == 1) return 1;
		
		return Fibonacci(N-1) + Fibonacci(N-2);
	}import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		System.out.println(Fibonacci(N));
		
		
		
	}
	// Recursive method for getting the fibonacci number for N
	public static int Fibonacci(int N) {
		if(N == 0) return 0;
		if(N == 1) return 1;
		
		return Fibonacci(N-1) + Fibonacci(N-2);
	}
	
	
}반응형
    
    
    
  'Projects > 백준 문제' 카테고리의 다른 글
| 백준 11654 자바 문제 아스키코드 변환 (0) | 2022.02.21 | 
|---|---|
| Baekjoon 10872 java factorial (0) | 2022.02.19 | 
| 백준 15596번 자바 문제 (0) | 2022.02.07 | 
| 백준 3444번 자바 문제 평균은 되겠지 (0) | 2022.02.07 | 
| 백준 8958번 자바 문제 OX퀴즈 (0) | 2022.02.07 | 
