FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ThinkRubyBuild/code/ackermann.py at master · learnbyexample/ThinkRubyBuild · GitHub
learnbyexample
/
ThinkRubyBuild
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
32
Code
Issues
7
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
ThinkRubyBuild
/
code
/
ackermann.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (19 loc) · 573 Bytes
Breadcrumbs
ThinkRubyBuild
/
code
/
ackermann.py
Copy path
File metadata and controls
29 lines (19 loc) · 573 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""This module contains a code example related to
Think Python, 2nd Edition
by Allen Downey
http://thinkpython2.com
Copyright 2015 Allen Downey
License: http://creativecommons.org/licenses/by/4.0/
"""
from
__future__
import
print_function
,
division
def
ackermann
(
m
,
n
):
"""Computes the Ackermann function A(m, n)
See http://en.wikipedia.org/wiki/Ackermann_function
n, m: non-negative integers
"""
if
m
==
0
:
return
n
+
1
if
n
==
0
:
return
ackermann
(
m
-
1
,
1
)
return
ackermann
(
m
-
1
,
ackermann
(
m
,
n
-
1
))
print
(
ackermann
(
3
,
4
))
Back
|
FazBrowse Home
|
New Git URL