For - repeat loop

-2

Hello, I'm new here and in the programming world. I would like to know how to do the last part of this exercise, using For. So far I've done this:

for(int i = 1; i<=100; i++) {
    if(i%2==0) {
        System.out.println(i+" é par");
    }else {
        System.out.println(i+" é ímpar");
    }

    if(i%3==0){
        System.out.println("é múltiplo de 3");
    }

    if(i%4==0) {
        System.out.println("múltiplo de 4");
    }

    
asked by anonymous 12.07.2018 / 00:29

1 answer

1

The second part of your problem:

if (i % 5 == 0){
    for(int a = 0; a < i; a++){
        if(a % 5 == 0){
            System.out.println("O número " + a + "é multiplo de 5 e anterior a " + i);

        }
    }
}

Regarding prime numbers, I did not understand which number should be compared.

    
12.07.2018 / 01:14