코딩테스트/백준
[백준-자바] 10870번 피보나치 수 5 / 2022.03.22
강원대목동녀
2022. 3. 22. 14:59
https://www.acmicpc.net/problem/10870
import java.util.Scanner;
public class Main {
public static int factorial(int n){
if(n==0)
return 0;
if(n==1)
return 1;
return factorial(n-2)+factorial(n-1);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
System.out.println(factorial(N));
}
}