Skip to content

Desafio 14 e 17 #10

Description

@jjgirotto

Oi Cami, tudo bem?
Estou com dificuldade no desafio 14 e 17 por conta dos números primos.
Poderia me ajudar com o código por favor?
tentei o 14 assim:
public class Desafio14 {
public static void main(String[] args) {
List numeros = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3);

    //Encontre o maior número primo da lista:
    int maiorPrimo = numeros.stream()
        .filter(n -> (n % n == 0 && n % 1 == 0));
        .mapToInt(Integer::intValue)
        .max()
    System.out.println(maiorPrimo);
}

}
mas não faz sentido, então não consegui fazer o 17 por ser parecido também

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions