Sudan function: Difference between revisions

add JS implementation
(create Sudan function entry; add Hoon implementation)
 
(add JS implementation)
Line 31:
x
$(n (dec n), x $(n n, x x, y (dec y)), y (add $(n n, x x, y (dec y)) y))
</lang>
 
=={{header|Javascript}}==
<lang Javascript>
/**
* @param {bigint} n
* @param {bigint} x
* @param {bigint} y
* @returns {bigint}
*/
function F(n, x, y) {
if (n === 0n) {
return x + y;
}
 
if (y === 0n) {
return x;
}
 
return F(n - 1n, F(n, x, y - 1n), F(n, x, y - 1n) + y);
}
</lang>