MiroslavKisov

ListOfPredicates

Feb 5th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ListOfPredicates
  6. {
  7.     public class StartUp
  8.     {
  9.         public static void Main()
  10.         {
  11.             int range = int.Parse(Console.ReadLine());
  12.             var dividers = Console.ReadLine()
  13.                 .Split(new string[] { }, StringSplitOptions.RemoveEmptyEntries)
  14.                 .Select(int.Parse).ToList();
  15.             List<int> numbers = new List<int>();
  16.             for (int i = 1; i <= range; i++)
  17.             {
  18.                 bool isGood = true;
  19.                 for (int j = 0; j < dividers.Count; j++)
  20.                 {
  21.                     if (i % dividers[j] != 0)
  22.                     {
  23.                         isGood = false;
  24.                         break;
  25.                     }
  26.                 }
  27.                 if (isGood)
  28.                 {
  29.                     numbers.Add(i);
  30.                 }
  31.             }
  32.             Console.WriteLine(string.Join(" ",numbers));
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment