Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class LeastMajorityMultiple
- {
- static void Main()
- {
- //Telerik Academy
- //Given five positive integers, their least majority multiple is the smallest positive integer that is divisible by at least three of them.
- //Your task is to write a program that for given distinct integers a, b, c, d and e, returns their least majority multiple.
- //For example if we have 1, 2, 3, 4 and 5 the majority multiple of the given five numbers is 4 because it is divisible by 1, 2, and 4.
- int[] numsArray = new int[5];
- for (int counter = 0; counter < 5; counter++)
- {
- int inputNum = int.Parse(Console.ReadLine());
- numsArray[counter] = inputNum;
- }
- for (int i = 1; true; i++)
- {
- int count = 0;
- for (int index = 0; index < 5; index++)
- {
- if (i % numsArray[index] == 0)
- {
- count++;
- }
- }
- if (count >= 3)
- {
- Console.WriteLine(i);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement