Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int rec(int x, int a,int n) {
  5.     x++;
  6.     if (a == n) {
  7.         return 0;
  8.     }
  9.     if (x == n) {
  10.         return a * (a - (x*n));
  11.         }
  12.     if (x > 0) {
  13.         return a * rec(x, a, n);
  14.         }  
  15. }
  16.  
  17. int main() {
  18. int a, n, result;
  19. int x = 0;
  20. cout << "A: ";
  21. cin >> a;
  22. cout << "N: ";
  23. cin >> n;
  24. result = rec(x, a, n);
  25. cout << result << endl;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement