Created
February 28, 2011 21:58
-
-
Save strax/848129 to your computer and use it in GitHub Desktop.
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
var depth = 1, invocations = 0, substractions = 0, edge = 0; | |
function f(x, y, z) { | |
if(y < x) { | |
// Increment the counters | |
++depth | |
substractions += 3 | |
if(depth > edge) edge = depth | |
console.log("Recursion depth: %d", depth) | |
z = f(f(x - 1, y, z), f(y - 1, z, x), f(z - 1, x, y)) | |
// We are back | |
--depth | |
} | |
return z | |
} | |
var x = 18, y = 12, z = 6 | |
f(x, y, z) | |
console.log("Maximum recursion depth: %d", edge) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment