Try
[Programmers/C++] 피보나치 수 본문
#include <string>
#include <vector>
using namespace std;
int solution(int n) {
int answer = 0;
int a = 0;
int b = 1;
int c = 0;
for(int i = 1; i < n; i++){
c = (a + b) % 1234567;
a = b;
b = c;
}
return c;
}
출처
https://programmers.co.kr/learn/courses/30/lessons/12945?language=cpp#
'Algorithm > Programmers' 카테고리의 다른 글
[Programmers/C++] 소수의 합 (0) | 2019.04.30 |
---|---|
[Programmers/C++] N개의 최소공배수 (0) | 2019.04.17 |
[Programmers/C++] 탑 (0) | 2019.04.16 |
[Programmers/C++] 약수의 합 (0) | 2019.04.12 |
[Programmers/C++] 문자열 내 p와 y의 개수 (0) | 2019.04.12 |
Comments