Pastebin
API
tools
faq
paste
Login
Sign up
SHARE
TWEET
Untitled
a guest
Oct 19th, 2017
77
0
Never
Add comment
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!
text
0.18 KB
| None
|
0
0
raw
download
clone
embed
print
report
# 複雜度 O(n)
input = gets
def fib_dy(n, f = [0, 1])
if n >= f.length
for i in f.length..n
f[i] = f[i-1] + f[i-2]
end
end
return f[n]
end
puts fib_dy(input.to_i)
Add Comment
Please,
Sign In
to add comment
Public Pastes
Pastebin.ai - #1 Pastebin alternative
PHP | 27 min ago | 0.85 KB
🤑 G2A.com Free Gift Card Guide May 2024 FIX 🎁
GetText | 37 min ago | 0.38 KB
snowybot
JavaScript | 42 min ago | 2.73 KB
PYTHON
C | 44 min ago | 0.68 KB
startup.lua
Lua | 47 min ago | 0.77 KB
importarProgramas.lua
Lua | 56 min ago | 1.17 KB
🤑 G2A.com Free Gift Card Guide May 2024 FIX 🤑
GetText | 1 hour ago | 0.39 KB
get_ip
Python | 1 hour ago | 1.87 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!