Guest User

Untitled

a guest
Mar 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. import java.text.*;
  4. import java.math.*;
  5. import java.util.regex.*;
  6.  
  7. public class Solution {
  8.  
  9. public static void main(String[] args) {
  10. Scanner in = new Scanner(System.in);
  11. int t = in.nextInt();
  12. long s=0L;
  13. for(int a0 = 0; a0 < t; a0++){
  14. int n = in.nextInt();
  15. long a=(n-1)/3;
  16. long b=3*a*(a+1)/2;
  17. long c=(n-1)/5;
  18. long d=5*c*(c+1)/2;
  19. long e=(n-1)/15;
  20. long f=15*e*(e+1)/2;
  21. /*
  22. for(int i=1;i<n;i++){
  23. if(i%5==0||i%3==0){
  24. s=s+i;
  25. }
  26. }*/
  27. s=b+d-f;
  28. System.out.println(s);
  29. s=0;
  30. }
  31. }
  32. }
Add Comment
Please, Sign In to add comment