Ackermann Function
#22
(07-16-2022, 11:47 PM)Jack Wrote: try a larger stack size, in my case 10MB worked, try with 16MB

I changed the stack to 26 MB but it just doesn't work with A(4,1).  Huh
Code: (Select All)
c_compiler\bin\g++ -s -Wfatal-errors -w -Wall qbx.cpp -lws2_32 -lwinspool parts\core\os\win\src.a -lopengl32 -lglu32 -lwinmm -lgdi32 -mwindows -static-libgcc -static-libstdc++ -D GLEW_STATIC -D FREEGLUT_STATIC -lksguid -lole32 -lwinmm -ldxguid -o ..\..\ -Wl, --stack, 26485760

It works up to A(3, 11), at A(3, 12) it's over again. There is now a time measurement for this.
Code: (Select All)
'Ackermann Funktion - 15. Juli 2022
'Absturz schon bei 4, 1 = 65533 (?)
'Na endlich funktioniert jetzt die Zeitmessung - 19. Juli 2022

Option _Explicit

Declare Function ackermann(m as Integer, n as Integer) as Long

Dim m, n As Long
Dim i, j As Integer
Dim t_start, t_end As Single

Print
Print "Ackermann Funktion - Geben Sie zwei Zahlen ein"
Print
Input "Zahl 1: ", m
Input "Zahl 2: ", n
Print

t_start = Timer
i = 0: j = 0
For i = 0 To m
  For j = 0 To n
    Print Using "Ackermann (#, ###) = ######"; i, j, ackermann(i, j)
  Next j
Next i

Print
t_end = Timer
Print Using "Verstrichene Zeit: ###.### Sekunden"; t_end - t_start;

End 'Hauptprogramm

Function ackermann (m As _Unsigned Integer, n As _Unsigned Integer)

  If m = 0 Then ackermann = n + 1

  If m > 0 And n = 0 Then
    ackermann = ackermann(m - 1, 1)
  End If
  If m > 0 And n > 0 Then
    ackermann = ackermann(m - 1, ackermann(m, n - 1))
  End If
End Function
Reply


Messages In This Thread
Ackermann Function - by Kernelpanic - 07-15-2022, 04:50 PM
RE: Ackermann Function - by bplus - 07-15-2022, 05:59 PM
RE: Ackermann Function - by Kernelpanic - 07-15-2022, 09:18 PM
RE: Ackermann Function - by Kernelpanic - 07-15-2022, 10:29 PM
RE: Ackermann Function - by James D Jarvis - 07-15-2022, 10:40 PM
RE: Ackermann Function - by Kernelpanic - 07-15-2022, 11:19 PM
RE: Ackermann Function - by James D Jarvis - 07-15-2022, 11:57 PM
RE: Ackermann Function - by bplus - 07-15-2022, 10:48 PM
RE: Ackermann Function - by Kernelpanic - 07-15-2022, 11:15 PM
RE: Ackermann Function - by bplus - 07-15-2022, 11:26 PM
RE: Ackermann Function - by Kernelpanic - 07-15-2022, 11:45 PM
RE: Ackermann Function - by Kernelpanic - 07-16-2022, 12:16 AM
RE: Ackermann Function - by James D Jarvis - 07-16-2022, 12:39 AM
RE: Ackermann Function - by bplus - 07-16-2022, 01:02 AM
RE: Ackermann Function - by Kernelpanic - 07-16-2022, 08:39 PM
RE: Ackermann Function - by James D Jarvis - 07-16-2022, 03:09 PM
RE: Ackermann Function - by bplus - 07-16-2022, 04:38 PM
RE: Ackermann Function - by Kernelpanic - 07-16-2022, 08:29 PM
RE: Ackermann Function - by Jack - 07-16-2022, 10:16 PM
RE: Ackermann Function - by Kernelpanic - 07-16-2022, 10:52 PM
RE: Ackermann Function - by Jack - 07-16-2022, 11:47 PM
RE: Ackermann Function - by Kernelpanic - 07-19-2022, 02:44 PM
RE: Ackermann Function - by Jack - 07-19-2022, 05:29 PM
RE: Ackermann Function - by Kernelpanic - 07-19-2022, 08:43 PM
RE: Ackermann Function - by Jack - 07-19-2022, 10:05 PM
RE: Ackermann Function - by Kernelpanic - 07-19-2022, 10:53 PM
RE: Ackermann Function - by Jack - 07-19-2022, 11:23 PM
RE: Ackermann Function - by Jack - 07-19-2022, 11:40 PM
RE: Ackermann Function - by Kernelpanic - 07-20-2022, 12:44 AM
RE: Ackermann Function - by Jack - 07-20-2022, 12:52 AM
RE: Ackermann Function - by Kernelpanic - 07-20-2022, 11:40 AM
RE: Ackermann Function - by Kernelpanic - 07-20-2022, 08:44 PM



Users browsing this thread: 9 Guest(s)