Skip to content

Instantly share code, notes, and snippets.

@mandos1995
Created April 5, 2023 10:29
let n = Int(readLine()!)!
var cache = [Int](repeating: 0, count: 1_000_001)
cache[1] = 1
cache[2] = 2
for i in 3...1_000_000 {
cache[i] = cache[i - 1] + cache[i - 2]
cache[i] %= 15746
}
print(cache[n])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment