In the following code, I wrote a function recursively which should return a value, and really when two numbers are equal it returns, in the function I did not use the return and she is still working, I'd love to get an answer to why it works?
#include <iostream>
#include <string.h>
using namespace std;
int gcd(int num1, int num2);
void main()
{
int ret_num = gcd(24, 60);
cout << ret_num << endl;
}
int gcd(int num1, int num2)
{
if (num1 == num2)
return num1;
else
{
if (num1 < num2)
gcd(num1, num2 - num1);
else
gcd(num2, num1 - num2);
}
}