Advertisement
myloyo

8.2.9

Mar 2nd, 2023 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int f(int n) {
  6.     if (n != 0) {
  7.         return n + f(n - 1);
  8.     }
  9.     else if (n == 0) {
  10.         return 0;
  11.     }
  12. }
  13. int main() {
  14.     int m, k;
  15.     cin >> m >> k;
  16.     cout << f(m) + f(2 * k);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement