fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. int n1 = 3;
  12. int n2 = 5;
  13. int result = 0;
  14.  
  15. for(int i = 1; i < 1000; i++){
  16. result = (i % n1 == 0 || i % n2 == 0)? result += i : result;
  17. }
  18. System.out.println("A soma dos multiplos de 3 e 5 abaixo de 1000, é: " +result);
  19. }
  20. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
A soma dos multiplos de 3 e 5 abaixo de 1000, é: 233168