Ackermann Function - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Works in Progress (https://staging.qb64phoenix.com/forumdisplay.php?fid=9) +---- Thread: Ackermann Function (/showthread.php?tid=617) |
Ackermann Function - Kernelpanic - 07-15-2022 The Ackermann function, but the program crashes as soon as one enter "ackermann(4, 1)". Why? The result of (4, 1) is 65533, which is in range. The program crashes, both in QB64 and in C (GCC - WinGW 11.02). Code: (Select All) 'Ackermann Funktion - 15. Juli 2022 RE: Ackermann Function - bplus - 07-15-2022 (07-15-2022, 04:50 PM)Kernelpanic Wrote: The Ackermann function, but the program crashes as soon as one enter "ackermann(4, 1)". Why? Because the Integer Range is +- 32K and change. Try _Unsigned Long or _Unsigned _Integer64 IF the numbers and calculations with them are Always Positive (no big variable subtractions) that will get you the greatest upper limit. Of what use are the Ackermann numbers? RE: Ackermann Function - Kernelpanic - 07-15-2022 Quote:Because the Integer Range is +- 32K and change. Try _Unsigned Long or _Unsigned _Integer64 IF the numbers and calculations with them are Always Positive (no big variable subtractions) that will get you the greatest upper limit. The number 65533 cannot be outside of "Long" because "Long" has a range from: LONG integer values range from -2147483648 to 2147483647 It's like Fibonacci numbers: interesting exercises. In addition, these numbers play an important role in biology. The Ackermann function it is about the time. That early used to work, I wrote the program in QuickC about 25 years ago. At that time you could still measure the time with simple numbers, but not anymore today, because small numbers are too fast. Ackermannfunktion It doesn't work with "_Integer64" neither. The worm is in there. RE: Ackermann Function - Kernelpanic - 07-15-2022 No, it can't be because of "Long". Ackermann(3, 11) - (3, 12) is out of range. RE: Ackermann Function - James D Jarvis - 07-15-2022 Looks like you are getting a stack overflow due to the depth of the recursion. RE: Ackermann Function - bplus - 07-15-2022 It is a recursive problem. I made everything _Unsigned _integer64 and got the little circle swirl before QB64 bugs out. RE: Ackermann Function - Kernelpanic - 07-15-2022 (07-15-2022, 10:48 PM)bplus Wrote: It is a recursive problem. I made everything _Unsigned _integer64 and got the little circle swirl before QB64 bugs out. What and which? All variables? Please, show the source code. I can't. RE: Ackermann Function - Kernelpanic - 07-15-2022 (07-15-2022, 10:40 PM)James D Jarvis Wrote: Looks like you are getting a stack overflow due to the depth of the recursion. Yes, but the overflow should not occur at A(4, 1). RE: Ackermann Function - bplus - 07-15-2022 Consolation prize: FreeBasic can't do any better! http://www.rosettacode.org/wiki/Ackermann_function#FreeBASIC Code: (Select All) _Define A-Z As _UNSIGNED _INTEGER64 RE: Ackermann Function - Kernelpanic - 07-15-2022 Quote:Consolation prize: FreeBasic can't do any better! http://www.rosettacode.org/wiki/Ackerman...#FreeBASIC Thanks! "C" can it: Only "int" -> Ackermann Funktion . . . but by myself the same problem. Code & screenshot. Code: (Select All) //Ackermann Funktion rekursiv - 15. Juli 2022 |