๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ”‘ ์•Œ๊ณ ๋ฆฌ์ฆ˜/๋ฐฑ์ค€ Python

๋ฐฑ์ค€2748๋ฒˆ ํŒŒ์ด์ฌ ํ”ผ๋ณด๋‚˜์น˜์ˆ˜2 #14-1)๋™์ ๊ณ„ํš๋ฒ•1

by Tamii 2020. 10. 21.
๋ฐ˜์‘ํ˜•

๋‚ด ํ’€์ด

n=int(input())

arr=[0 for i in range(n+1)]
arr[1]=1
for i in range(2,n+1):
	arr[i]=arr[i-1]+arr[i-2]


print(arr[-1])

arr = [n๋งŒํผ์˜ ๋ฆฌ์ŠคํŠธ ์ž๋ฆฌ๋ฅผ ๋งŒ๋“ค์–ด์„œ]

ํ•˜๋‚˜์”ฉ ๋„ฃ๋Š” ๋ฐฉ๋ฒ•

 

n=int(input())

arr=[0,1]
for i in range(2,n+1):
	arr.append(arr[i-1]+arr[i-2])


print(arr[n])

์ด๋ ‡๊ฒŒ ๋ฐ”๋กœ ๋„ฃ๋Š” ๊ฒฝ์šฐ๋„ ์žˆ๋‹ค.

๋Œ“๊ธ€