archangelmihail

LeastMajority

Dec 3rd, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LastMajority
  8. {
  9.     class LastMajority
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] numbers = new int[5];
  14.             for (int i = 0; i < 5; i++)
  15.             {
  16.                 numbers[i] = int.Parse(Console.ReadLine());
  17.             }
  18.             int leastMajority = 1;
  19.             int count = 0;
  20.             bool stop = false;
  21.             while (!stop)
  22.             {
  23.                 for (int i = 0; i < 5; i++)
  24.                 {
  25.                     if (leastMajority % numbers[i] == 0)
  26.                     {
  27.                         count++;
  28.                     }
  29.                 }
  30.                 if (count == 3)
  31.                 {
  32.                     stop = true;
  33.                 }
  34.                 else
  35.                 {
  36.                     count = 0;
  37.                     leastMajority++;
  38.                 }
  39.                
  40.             }
  41.             Console.WriteLine(leastMajority);
  42.            
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment