怎样让C++程序中第一次循环的值加上第二次循环的值,第三次,第四次到N次的和?

(填在n1后面的括号里)(如果有别的办法可以重写)

再次感谢各位大佬的支持(^\/^)!!!

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int n=1,n1;
    while(n<=100){
        if(n%3==0){
            n1=(/*n+第二、+三、+四...+100次循环后输出的n*/);
            cout<<n1<<endl;
        }
        n+=1;
    }
    return 0;
}
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int n=1,n1=0;
    while(n<=100){
        if(n%3==0){
            n1+=n;

        }
        n+=1;
    }
                    cout<<n1<<endl;
    return 0;
}

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int n=1,n1;
    while(n<=100){
        if(n%3==0){
            n1=n1+n;
    
        }
        n+=1;
    }
    cout<<n1<<endl;
    return 0;
}