Advertisement
Josif_tepe

Untitled

May 28th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int p, d, n, zbir = 0;
  8.     cin >> p >> d >> n;
  9.     for (int i = 1; i < n; i++)
  10.     {
  11.         if (i == 1)
  12.         {
  13.             zbir += p;
  14.         }
  15.         else {p += d;
  16.         zbir += p;
  17.         }
  18.     }
  19.     cout << zbir << endl;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement