John_IV

Untitled

Jan 10th, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. public class E09ListOfPredicates {
  2.     public static void main(String[] args) throws IOException {
  3.         BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
  4.  
  5.         int n = Integer.parseInt(rd.readLine());
  6.         int[] nums = Arrays.stream(rd.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
  7.         IntPredicate divided = num -> {
  8.             for (int div : nums) if (num % div != 0) return false;
  9.             return true;
  10.         };
  11.  
  12.         IntStream.rangeClosed(1, n).filter(divided).forEach(d -> System.out.print(d + " "));
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment