fork(16) download
  1. class Main {
  2. public static void main(String[] args) {
  3.  
  4. int N = 1000;
  5. int result = sum(3, N-1) + sum(5, N-1) - sum(15, N-1);
  6.  
  7. System.out.println(result);
  8. }
  9.  
  10. public static int sum(int n, int N) {
  11. return n * (N/n) * (N/n + 1)/2;
  12. }
  13. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
233168