Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class E09ListOfPredicates {
- public static void main(String[] args) throws IOException {
- BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
- int n = Integer.parseInt(rd.readLine());
- int[] nums = Arrays.stream(rd.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
- IntPredicate divided = num -> {
- for (int div : nums) if (num % div != 0) return false;
- return true;
- };
- IntStream.rangeClosed(1, n).filter(divided).forEach(d -> System.out.print(d + " "));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment