문제 설명
해결과정
Solution.java
class Solution {
public int solution(int n) {
int answer = 0;
int first = 1;
int second = 2;
int third = 0;
int cnt = 3;
while(cnt != n+1) {
third = (first + second) % 1000000007;
first = second%1000000007;
second = third%1000000007;
cnt++;
}
answer = third;
return answer;
}
}
Java
복사