I have this code in Long
working normally:
public static void main(String args[]){
List<Long> lista = new ArrayList();
for(long a = 1; a <= 100; a++){
if(a%2==0) {}
else if (a%3==0){}
else {
lista.add(a);
}
}
System.out.println(lista);
}
}
ImadethisothercodeinBigInteger
forthesamefunction,butdoesnotwork:
publicstaticvoidmain(String[]args){List<BigInteger>lista=newArrayList();BigIntegercomeço=newBigInteger("1");
BigInteger fim = new BigInteger("100");
BigInteger n0 = new BigInteger("0");
BigInteger n2 = new BigInteger("2");
BigInteger n3 = new BigInteger("3");
for (BigInteger a = começo; a.compareTo(fim) <= 0; a = a.add(BigInteger.ONE)) {
if (a.divide(n2)==n0){}
else if (a.divide(n3)==n0){}
else {
lista.add(a);
}
}
System.out.println( lista );
}
}