Skip to content

Instantly share code, notes, and snippets.

@sing1ee
Created July 11, 2012 03:09
Show Gist options
  • Save sing1ee/3087723 to your computer and use it in GitHub Desktop.
Save sing1ee/3087723 to your computer and use it in GitHub Desktop.
fibonacci by dynamic programming
# !/usr/bin/python
# -*- encoding: utf-8 -*-
import sys
dp = []
for i in range(100):
dp.append(0)
dp[0] = 0
dp[1] = 1
dp[2] = 2
for i in range(3, 100):
dp[i] = dp[i - 1] + dp[i - 2]
print dp[int(sys.argv[1])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment