Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
140byt.es -- Ackermann function

A 49 byte version of the famous Ackermann function. You will most likely hit the stack limit very early.

function a(n,m){
return !n ? // if n is zero
m+1 : // return m+1
a( n - 1, // else
m ? // if m is bigger than zero
a( n, m- 1) : // return a(n - 1, a(n, m - 1))
1 // return a(n - 1, 1)
)
}
function a(n,m){return!n?m+1:a(n-1,m?a(n,m-1):1)}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Kambfhase
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "ackermann49",
"description": "a 49 byte version of the ackermann function",
"keywords": [
"140bytes",
"ackermann"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.