Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int k;
- cin >> k;
- int pocetok = 1;
- int zbir = 0;
- // pocetok = 1, i = 1
- // pocetok = 1 + 3 = 4, i = 2
- // pocetok = 4 + 3 = 7, i = 3
- // pocetok = 7 + 3 = 10, i = 4
- for(int i = 1; i <= k; i++) { // za site broevi od 1 do k
- zbir += pocetok;
- pocetok += 3; // 1 + 3 = 4
- // 4 + 3 = 7
- // 7 + 3 = 10
- // 10 + 3 = 13 ...
- }
- cout << zbir << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment