Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int product(int a, int b) {
  5.     if(b == 0) {
  6.         return 0;
  7.     }
  8.     return a + product(a, b - 1);
  9. }
  10. int main()
  11. {
  12.     int a, b;
  13.     cin >> a >> b;
  14.     cout << product(a, b) << endl;
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement