summaryrefslogtreecommitdiff
path: root/progs/a151.py
diff options
context:
space:
mode:
Diffstat (limited to 'progs/a151.py')
-rw-r--r--progs/a151.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/progs/a151.py b/progs/a151.py
new file mode 100644
index 0000000..030c8b6
--- /dev/null
+++ b/progs/a151.py
@@ -0,0 +1,7 @@
+def jacobsthal_num(n):
+ dp = [0] * (n + 1)
+ dp[0] = 0
+ dp[1] = 1
+ for i in range(2, n+1):
+ dp[i] = dp[i - 1] + 2 * dp[i - 2]
+ return dp[n] \ No newline at end of file