Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int rec(int x, int a,int n) {
- x++;
- if (a == n) {
- return 0;
- }
- if (x == n) {
- return a * (a - (x*n));
- }
- if (x > 0) {
- return a * rec(x, a, n);
- }
- }
- int main() {
- int a, n, result;
- int x = 0;
- cout << "A: ";
- cin >> a;
- cout << "N: ";
- cin >> n;
- result = rec(x, a, n);
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement