Advertisement
Josif_tepe

Untitled

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