Questions tagged [ackermann]

A well-defined total function which is computable but not primitive recursive. It grows faster than an exponential function, or even a multiple exponential function.

55 questions
1
vote
3 answers

Can the standard Ackermann be optimized?

The standard Ackermann formula as written in Java: public static int ack(int x, int y) { if (x == 0) { return y + 1; } else if (y == 0) { return ack(x-1, 1); } else { // perforce (x > 0)…
user3063864
  • 661
  • 2
  • 7
  • 18
0
votes
0 answers

Ackermann Function in React Native very slow

I want top calculate the Ackermann Function and the Power of a number iterative. But both functions Work very slow. I already tried an empty App,but it's already slow and I didn't know why. We compare with flutter and Maui. React Native is very very…
0
votes
0 answers

Getting seg fault for writing procedures in x86 32-bit compiled using NASM

Ackermann’s function A(m,n), where m ≥ 0 and n ≥ 0, is defined as A(0, n) = n + 1 A(m + 1, 0) = A(m, 1) A(m + 1, n + 1) = A(m,A(m+1,n)) I am trying to write the code for the above function but I am getting seg fault for m=1,n=1. What am I doing…
Mike
  • 9
  • 3
0
votes
0 answers

How do you increase the stack size using MinGw G++ compiler?

I am trying to run the Ackermann function1 and I am having an issue. I am trying to run the program through my Command Prompt, on a Windows 10 machine, and a few seconds after reaching the value pair (4,0) the program stops. I am assuming because it…
kemenike
  • 1
  • 1
0
votes
0 answers

Ackermann real numbers python

How can one compute the Ackermann function over nonnegative real numbers in Python per this question on Mathoverflow? Here is my code for integers. def naive_ackermann(m, n): global calls calls += 1 if m == 0: return n + 1 …
Haggis
  • 11
  • 1
0
votes
1 answer

Segmentation fault for numbers too big for Ackermann's function

Why is this failing? I have written Ackermann's function in C and used longs to make sure that no number will be too small. Yet, when I go above (including) 4 for m and n, it gives me a segmentation fault: 11. Does anyone know why? #include…
0
votes
0 answers

cout fails when printing large numbers

I'm trying to print Ackermann's function values in C++ the first 50 results are right but as the number starts to grow out the last digit start to be printed wrongly. for example: // consider ack(m, n) as the ackermann function case ack(3, 51)…
Kakiz
  • 1,145
  • 1
  • 9
  • 18
0
votes
0 answers

Why does python stop computing without throwing an error while calculating Ackermann?

I wrote code to calculate the Ackermann function and store the results, but at some random point it just stops (only for the lookup version though), the normal version just runs without stopping. It can't be the recursion limit, maybe the…
Orión González
  • 309
  • 2
  • 14
0
votes
0 answers

Ackermann Funktion: How to implement "deep recursion"?

I recently stumbled across the Ackermann function, which uses a kind of "nested recursion" to calculate a value. I implemented my own take on the function in C++, which caches intermediate results to speed up the calculation (compare implementation…
User12547645
  • 6,955
  • 3
  • 38
  • 69
0
votes
2 answers

Implementing Ackermann Function by Java with BigInteger support

I'm getting StackOverflowError (Exception in thread "main" java.lang.StackOverflowError) for the following code. But the program works fine for m=3, n=3 (or other lower values) but does not work for m=4 and n=2 or 3. public class…
User_67128
  • 1,230
  • 8
  • 21
0
votes
0 answers

Ackermann function in assembly - stuck in infinite recursion

I'm trying to write Ackermann function as assembly code(in ARMV8). (http://mathworld.wolfram.com/AckermannFunction.html https://en.wikipedia.org/wiki/Ackermann_function) It requires recursion. My code goes into an infinite recursion. I couldn't find…
bo_
  • 35
  • 8
0
votes
0 answers

How do I allow python to recursively compute beyond the set recursive limit?

Just out of curiosity, I decided to take an example of a recursive function. So, I have this recursive function (The Ackermann function): def ack(a, b): if a == 0: return b + 1 elif b == 0: return ack(a - 1, 1) else: …
0
votes
1 answer

A double recursive function

I wanted to code a function (modified version of Ackermann's funciton) defined in A Tour Through Mathematical Logic by S. Wolf as follows: A(0,n)=n+1 for every n A(1,0)=2 A(2,0)=0 A(m+3,0)=1 for every m A(m+1,n+1)=A(m,A(m+1,n)) for every m and…
Scientifica
  • 169
  • 1
  • 10
0
votes
2 answers

Memoization with Ackermann function C++

Ok, this is for a homework assignment, so please just try to direct me without giving me the straight-up answer. I'm trying to institute memoization with the Ackermann function (C++). It does not do what I would expect when reaching Ackermann(1,2).…
davejr72
  • 13
  • 6
0
votes
0 answers

Ruby memoize'd routine lags?

REVISION #3 I'm trying to develop an Ackermann in Ruby using original 3-arg model function. My attempt to do so appears to show the memoize'd version - ack taking longer than the raw version - raw - so obviously "something" is wrong: 1% ruby…
slashlos
  • 913
  • 9
  • 17