Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int endNumber = int.Parse(Console.ReadLine());
- int[] dividers = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- HashSet<int> sortedDividers = new HashSet<int>();
- foreach (int number in dividers)
- {
- sortedDividers.Add(number);
- }
- if (endNumber <= 0)
- {
- return;
- }
- Func<HashSet<int>, int, bool> isDevisible = (allDividers, number) =>
- {
- return allDividers.All(x => number % x == 0);
- };
- int[] allDevisibleNumbers = Enumerable.Range(1, endNumber).Where(number => isDevisible(sortedDividers, number)).ToArray();
- Console.WriteLine(string.Join(" ", allDevisibleNumbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement