IT/알고리즘
[백준] 피보나치
남갯
2024. 10. 21. 21:29
SMALL
https://www.acmicpc.net/problem/10870
fun main() = with(System.`in`.bufferedReader()) {
val count = readLine().toInt()
val array = Array<Int>(count + 1) { 0 }
array[0] = 0
if (count >= 1) {
array[1] = 1
}
for (i in 2..count) {
array[i] = array[i - 1] + array[i - 2]
}
println(array[count])
}
LIST