Need help on a recrusive function

the program works fine but int number can't go over on certain number
lets say x and y are are input here from main function so
cin >> x,y
NT(x), ET(y), NET(z) is recursive function for factorial or n!.
one below is function for path so if i have 3 = x 2 = y
i have 10 possible path.
but i notice that you can't go over after 7. it works fine until x = 6 and y =6
but rest of them is not working like it suppose to. how can I fix this ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int Path(int x, int y)
{
	int N,E,NE, z;
	N = NT(x);
	E = ET(y);
	z = x + y;
	NE = NET(z);
	if (N == 0 && E == 0 || N == 1 && E ==1
		|| N == 1 && E == 0 || N==0 && E==1)
		return 1;
	else
	{
		return NE/(N*E);
	}
}

Last edited on
Without seeing more code I cannot really say, but I strongly suspect you've got some integer overflow going on somewhere. An int, on many systems, is 32 bits, meaning that it has a maximum value of 2,147,483,647.

Try changing your ints to long int and see if you can get to 8.

Hope this helps.
Topic archived. No new replies allowed.