Advertisement
ElviraPetkova

09. List Of Predicates - 4

Oct 10th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _01._Basic_Stack_Operations__
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int n = int.Parse(Console.ReadLine());
  12.             int[] delimeters = Console.ReadLine().Split().Select(int.Parse).ToArray();
  13.  
  14.             Func<int, int, bool> isDivisible = (x, y) => x % y == 0;
  15.             List<int> numbers = new List<int>();
  16.  
  17.             for (int i = 1; i <= n; i++)
  18.             {
  19.                 if(delimeters.Where(x=> isDivisible(i, x)).Count() == delimeters.Count())
  20.                 {
  21.                     numbers.Add(i);
  22.                 }
  23.                
  24.             }
  25.            
  26.             Console.WriteLine(string.Join(" ",numbers));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement