fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.BigInteger;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. BigInteger start = new BigInteger("1");
  14. BigInteger limit = new BigInteger("50");
  15. BigInteger n1 = new BigInteger("3");
  16. BigInteger n2 = new BigInteger("7");
  17.  
  18. for (BigInteger a = start, b = start; a.compareTo(limit) <= 0 && b.compareTo(limit) <= 0;) {
  19. BigInteger copas3 = a.multiply(n1);
  20. BigInteger copas7 = b.multiply(n2);
  21.  
  22. int comparacao = copas3.compareTo(copas7);
  23. if (comparacao == 0) {
  24. System.out.println(copas3);
  25. }
  26.  
  27. if (comparacao <= 0) {
  28. a = a.add(BigInteger.ONE);
  29. }
  30. else {
  31. b = b.add(BigInteger.ONE);
  32. }
  33. }
  34. }
  35. }
Success #stdin #stdout 0.06s 4575232KB
stdin
Standard input is empty
stdout
21
42
63
84
105
126
147