#include <iostream>
using namespace std;

int main(){
    int n;
    cin>>n;
    int s=0;
    int m=0;
    for(int i=1;i<n;i++){
        if(i%3==0||i%5==0){
            s+=i;
        }if(i%15==0){
            m+=i;
        }
    }cout<<s-m;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: