How to calculate the series 2 15 41 80 132 197 275 366 470 ... N in C++

1 Answer

0 votes
#include <iostream>

int main() {
    int a = 2, total = 9;
    
    for (int i = 1; i <= total; i++) {
        std::cout << a << " ";
        a += 13 * i;
    }
}





/*
run:

2 15 41 80 132 197 275 366 470 

*/

 



answered Apr 2, 2022 by avibootz
edited Apr 3, 2022 by avibootz
...