백준 2747

soss·2022년 10월 4일
0
post-thumbnail

https://www.acmicpc.net/problem/2748

n = int(input())

n_list = [0,1]

for i in range(n-1):
    n_list.append(n_list[i] + n_list[i+1])

print(n_list[n])

피보나치 수는 0과 1로 시작하기 때문에 미리 배열로 선언을 해두었다.
후에 입력한 수(n)만큼 연속되는 두 인덱스의 합을 배열로 추가하는 반복문을 사용했다.

profile
안녕하세요. 복습 목적으로 문제 풀이를 올리고 있습니다.

1개의 댓글

comment-user-thumbnail
2022년 10월 4일

피보나찌찌

답글 달기