Advertisement
Josif_tepe

Untitled

May 7th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     int n;
  6.     scanf("%d", &n);
  7.    
  8.     int brojac = 1;
  9.     int zbir = 0;
  10.     while(brojac <= n) {
  11.         zbir += brojac;
  12.         printf("%d\n", zbir);
  13.         brojac++;
  14.     }
  15.    
  16.    
  17.     return 0;
  18. }
  19. // 1, 2, 3, 4, 5
  20. // 0 + 1 = 1
  21. // 1 + 2 = 3
  22. // 3 + 3 = 6
  23. // 6 + 4 = 10
  24. // 10 + 5 = 15
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement