$dp = {} $dp[0] = 1 def f(n) $dp[n] ||= if n < 0 0 else res = f(n-1) + f(n-2) end end p f(gets.to_i)