solving Ackermann’s Function

I'm supposed to use Ackermann’s Function recursivly to solve for it but i keep getting the following error: Unhandled exception at 0x009328F9 in Assignment5E.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x001D2F4C).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <conio.h>

using namespace std;
int A(int m, int n);

void main(){
	cout << A(0,1);
	_getch();
}

int A(int m, int n){
	if (m = 0){
		return (n + 1);
	}
	else if (n = 0){
		return A(m-1, 1);
	}
	else{
		 return A(m-1, A(m, n-1));
	}
}
= is assignment
== tests for equality
Change your if statements.
Topic archived. No new replies allowed.