You are viewing a single comment's thread. Return to all comments →
A beautiful way to solve the problem with streams
class Prime { public void checkPrime(Integer... checks) { List<Integer> in = Arrays.stream(checks) .filter(i -> i != 1) .filter(check -> IntStream.range(2, check) .filter(c -> (check % c) == 0) .boxed().count() == 0) .collect(Collectors.toList()); System.out.println(in.stream().map(String::valueOf).collect(Collectors.joining(" "))); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Prime Checker
You are viewing a single comment's thread. Return to all comments →
A beautiful way to solve the problem with streams