Skip to content

Instantly share code, notes, and snippets.

@RussellAndrewEdson
Created April 11, 2015 03:27
Show Gist options
  • Save RussellAndrewEdson/988ee2cc19e0543cc4dd to your computer and use it in GitHub Desktop.
Save RussellAndrewEdson/988ee2cc19e0543cc4dd to your computer and use it in GitHub Desktop.
The recursive G function from Godel, Escher, Bach.
(defn g
"The recursive G function from Godel, Escher, Bach: takes
in an integer n and returns G(n) = n - G(G(n-1)), with G(0) = 0."
[n]
(if (= n 0)
0
(- n (g (g (- n 1))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment