* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.3 KiB
1.3 KiB
id, title, challengeType, videoUrl, dashedName
id | title | challengeType | videoUrl | dashedName |
---|---|---|---|---|
594810f028c0303b75339acf | 阿克曼功能 | 5 | ackermann-function |
--description--
Ackermann函数是递归函数的典型示例,尤其值得注意的是它不是原始递归函数。它的值增长非常快,其调用树的大小也是如此。
Ackermann函数通常定义如下:
$$ A(m,n)= \\ begin {cases} n + 1&\\ mbox {if} m = 0 \\\\ A(m-1,1)&\\ mbox {if} m> 0 \\ mbox {和} n = 0 \\\\ A(m-1,A(m,n-1))&\\ mbox {if} m> 0 \\ mbox {和} n> 0. \\ end {cases} $$它的论点永远不会消极,它总是终止。编写一个返回$ A(m,n)$的值的函数。任意精度是首选(因为函数增长如此之快),但不是必需的。
--hints--
ack
是一个功能。
assert(typeof ack === 'function');
ack(0, 0)
应该返回1。
assert(ack(0, 0) === 1);
ack(1, 1)
应该返回3。
assert(ack(1, 1) === 3);
ack(2, 5)
应该返回13。
assert(ack(2, 5) === 13);
ack(3, 3)
应该返回61。
assert(ack(3, 3) === 61);
--seed--
--seed-contents--
function ack(m, n) {
}
--solutions--
function ack(m, n) {
return m === 0 ? n + 1 : ack(m - 1, n === 0 ? 1 : ack(m, n - 1));
}