Hello, good, I'm doing a program where I must perform the division of two numbers and if it evaluates if the first number is divisible by the divisor, if so, print all the divisible divisible numbers. So far I did odd and even numbers, but it only works if I enter 2 or 3, what happens if I want to enter a 7 or an 8, I do not get their dividers, how could I do that? , that is, I want to enter any number and give me its first 10 divisible numbers. I hope it was clear. Now I leave you what I did:
public class Divisibles {
public static void main(String[] args) {
Scanner teclado = new Scanner (System.in);
int numero1 =0;
int numero2 = 0;
int par = 0;
int impar = 0;
int suma1=0;
int suma2=0;
System.out.println("Ingrese numero : ");
numero1 = teclado.nextInt();
System.out.println("Ingrese otro :");
numero2 = teclado.nextInt();
for(int i = 0 ; i<10 ; i++) {
if(numero1%numero2==0) {
if(numero2%2==0) {
par+=2; //tuve que realizar esto por que sino no
//salian numeros como el 16 o 18.
suma1=par;
System.out.println(suma1);
}
else if(numero2%3==0) {
impar+=3; //lo mismo aca le sume 3 por que no
//salian numeros como el 9
suma2=impar;
System.out.println(suma2);
}
}
}
}
}
Well I know that this program will work only for numbers divisible by 2 or 3, so if you have any idea of what could change, thank you:)