What approach did you use dear? Also, did you consider the traditional Arithematic Progression approach?

Here is my code if you want to have a look -

```
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(){
int t;
scanf("%d",&t);
for(int a0 = 0; a0 < t; a0++){
int n;
scanf("%d",&n);
long int counter=0,i,j,k,t3,t5,t15;
t3=(n-1)/3;//number of terms of 3
t5=(n-1)/5;//number of terms of 5
t15=(n-1)/15;//number of terms of 15
i=t3*(6+(t3-1)*3);//formula for sum of an AP- Sum= n/2 x (2a+(n-1)d)
j=t5*(10+(t5-1)*5);
k=t15*(30+(t15-1)*15);
counter=(i+j-k)/2;//counter stores the final ans. IDK why I named it that XD
printf("%ld\n",counter);
}
return 0;
}
```

EDIT-

Here is the corrected code-

```
#include<iostream>
using namespace std;
int main(){
int t;
cin >> t;
for(int a0 = 0; a0 < t; a0++){
long long mul_5, mul_3, mul_15, n, sum=0;
cin>>n;
mul_5 = 5 * ( (n-1)/5 * ( (n-1)/5+1))/2;
mul_3 = 3 * ( (n-1)/3 * ( (n-1)/3+1))/2;
mul_15 = 15 * ( (n-1)/15 * ( (n-1)/15+1))/2;
sum = mul_5 + mul_3 - mul_15; // AP of 3 and 5 minus 15 to remove duplicates
cout<<sum<<endl;
}
return 0;
}
```

You were doing a mistake in calculating the number of terms. The question says that the term must be STRICTLY less than N. Your code also included N.

Meaning, if N=10, your code gives 2 multiples of 5 in the range (5 and 10) while it should be one. Its easily corrected by subtracting 1 from N and then using it as usual.