#include <iostream>
using namespace std;
int multiples(int n, int m)
{
if (m < 1)
{
return 0;
}
cout << multiples(n, m - 1) << " " << n * m;
}
int main()
{
multiples(3, 4);
return 0;
}
I am trying to print the multiples of given number recursively in C++ but I’m not getting the desired output.
The first 1 digit of all output number is answer but the rest all the digits is same and idk what it is.
First, I thought its compiler problem but no its something else. Can anyone tell me why this is happening?
my output is
0 31878006336 61878006336 91878006336 12
expected output is
0 3 6 9 12`
New contributor
PK 6032 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2