You are viewing a single comment's thread. Return to all comments →
int main(){ int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n; cin >> n; long long sum=0;
long i= (n-1)/3 ,j = (n-1)/5 , k=(n-1)/15; sum= 3*(i*(i+1)/2)+ 5*(j*(j+1)/2) - 15*(k*(k+1)/2); cout<<sum<<"\n"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #1: Multiples of 3 and 5
You are viewing a single comment's thread. Return to all comments →
int main(){ int t; cin >> t; for(int a0 = 0; a0 < t; a0++){ int n; cin >> n; long long sum=0;