2748
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
int n = in.nextInt();
long Fn_2 = 0;
long Fn_1 = 1;
long result = 0;
for (int i = 0 ;i < n; i++) {
if (i == 0) {
result = Fn_1 + Fn_2;†
}
else if (i >= 1) {
result = Fn_1 + Fn_2;
Fn_2 = Fn_1 ;
Fn_1 = result;
}
}
System.out.println(result);
}
}
피보나치 수열 문제 + 타입을 고려해야하는 문제
https://velog.io/@juyeon10120/PS-6일차
해당 문제는 처리할수 있는 정수의 범위만 늘어난 문제이다. 풀이 알고리즘은 상단 링크를 들어가면 있다.