I have two 50-number formulas.
One has multiples of 3
and the other multiples of 7
.
Code:
public static void main(String[] args) {
BigInteger start = new BigInteger("1");
BigInteger limit = new BigInteger("50");
BigInteger n1 = new BigInteger("3");
BigInteger n2 = new BigInteger("7");
for (BigInteger a = start; a.compareTo(limit) <= 0; a = a.add(BigInteger.ONE)) {
BigInteger copas3 = a.multiply(n1);
BigInteger copas7 = a.multiply(n2);
System.out.println( copas3 );
System.out.println( copas7 );
}
}
See working on repl: link
I need only the numbers that are repeated between the two formulas to be printed. So, just:
21
42
63
84
105
126
147