Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Ackermann-function/Fantom/ackermann-function.fantom
Normal file
24
Task/Ackermann-function/Fantom/ackermann-function.fantom
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
class Main
|
||||
{
|
||||
// assuming m,n are positive
|
||||
static Int ackermann (Int m, Int n)
|
||||
{
|
||||
if (m == 0)
|
||||
return n + 1
|
||||
else if (n == 0)
|
||||
return ackermann (m - 1, 1)
|
||||
else
|
||||
return ackermann (m - 1, ackermann (m, n - 1))
|
||||
}
|
||||
|
||||
public static Void main ()
|
||||
{
|
||||
(0..3).each |m|
|
||||
{
|
||||
(0..6).each |n|
|
||||
{
|
||||
echo ("Ackerman($m, $n) = ${ackermann(m, n)}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue