Created
April 11, 2015 01:57
-
-
Save RussellAndrewEdson/55bd57a00da07f7c8243 to your computer and use it in GitHub Desktop.
The recursive F and M functions from Godel, Escher, Bach.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare f m) | |
(defn f | |
"The F function from Godel, Escher, Bach: takes in | |
an integer n and returns F(n) = n - M(F(n-1)), with F(0) = 1." | |
[n] | |
(if (= n 0) | |
1 | |
(- n (m (f (- n 1)))))) | |
(defn m | |
"The M function from Godel, Escher, Bach: takes in | |
an integer n and returns M(n) = n - F(M(n-1)), with M(0) = 0." | |
[n] | |
(if (= n 0) | |
0 | |
(- n (f (m (- n 1)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment