I am doing another recursive function - actually have the code working - but one of my required test sets is throwing an error??? The actual result should fit as an integer, i made it an unsigned long to leave plenty of room... but I keep getting the following error:
Unhandled exception at 0x00391e69 in MultiplicationRecursion.exe: 0xC00000FD: Stack overflow.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int multiData(unsignedlonglong X, unsignedlonglong Y)
return X + multiData(X,Y-1);
using 12345 & 90009 for input
i did the calculation on my calculator... should = 1,111,161,105.
is this a memory issue... i cannot see why it works for most things, and not for others especially when the end result is less than the max size of the data type..
Maybe 90,009 recursion iterations are too many for the stack. Replacing 90,009 with smaller numbers works fine. I even tried changing your return type to unsigned long long, but still ended up with segmentation faults with a five-digit second parameter. When I run your program, there is a segmentation fault at the 43,437th iteration.
Almost forgot. Why are you doing this instead of X*Y?
operator () is a function name of so-called function call operator as for example operator + or operator << are also corresponding function names. The second pair of parentheses serves to specify arguments for the function. For example