Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int n;
- scanf("%d", &n);
- int brojac = 1;
- int zbir = 0;
- while(brojac <= n) {
- zbir += brojac;
- printf("%d\n", zbir);
- brojac++;
- }
- return 0;
- }
- // 1, 2, 3, 4, 5
- // 0 + 1 = 1
- // 1 + 2 = 3
- // 3 + 3 = 6
- // 6 + 4 = 10
- // 10 + 5 = 15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement