This is Ackermann's Function implemented in a For loop.

I call it the Koop Loop.

From the mind of Tim Koop.

m
n

Using recursive Ackermann:

Koop's For Loop:

function a(m, n) { var v = [] var k = [{m,n}] for(var i = 0; i < k.length; i++) { var thisM = k[i].m var thisN = k[i].n var thisFound = typeof(v[thisM+","+thisN]) != "undefined" if (thisN == null) { var prevM = k[i-1].m var prevN = k[i-1].n var prevValue = v[prevM+","+prevN] if (typeof(prevValue) == "undefined") { k.splice(i, 0, null, {m:prevM, n:prevN}) continue } else { k[i].n = prevValue thisN = k[i].n } } if (!thisFound) { if (thisM == 0) { v[thisM+","+thisN] = thisN + 1 } else if (thisN == 0) { var otherValue = v[(thisM-1)+",1"] if (typeof(otherValue) != "undefined") { v[thisM+","+thisN] = otherValue } else { k.splice(i, 0, null, {m:thisM-1, n:1}) } } else { var nLess1Value = v[thisM+","+(thisN-1)] if (typeof(nLess1Value) != "undefined") { var otherValue = v[(thisM-1)+","+nLess1Value] if (typeof(otherValue) != "undefined") { v[thisM+","+thisN] = otherValue } else { k.splice(i, 0, null, {m:thisM-1, n:nLess1Value}) } } else { k.splice(i, 0, null, {m:thisM, n:thisN-1}, {m:thisM-1, n:null}) } } } } return v[k[k.length-1].m+","+k[k.length-1].n] }