PDA

View Full Version : Ackerman function



stapper
08-04-2017, 19:00
http://rosettacode.org/wiki/Ackermann_function



Uses "Console"

Dim i,j As Long

For i = 0 To 3
For j = 0 To 7
PrintL ("Ackermann " & i & " " & j & " " & ackermann(i,j))
Next
Next


Function ackermann(m As Long, n As Long)

If m = 0 Then
Function = n + 1
ElseIf n = 0 Then
Function = ackermann(m-1,1)
Else
Function = ackermann(m-1,ackermann(m,n-1))
End If

End Function

PrintL "Press a key to end program"

'---Wait for a key press
WaitKey