Advertisement
Josif_tepe

Untitled

Nov 26th, 2023
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     cin >> n;
  11.     int brojac = 1;
  12.     int sum = 0;
  13.    
  14.     while(brojac <= n) {
  15.        
  16.         sum += brojac;
  17.        
  18.         brojac++;
  19.        
  20.     }
  21.    
  22.     cout << sum << endl;
  23.    
  24.  
  25.    
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement