ellapt

LeastMajorMultiple

Dec 18th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System;
  2.  
  3. class LeastMajorMultiple
  4. {
  5. static void Main()
  6. {
  7. int a = int.Parse(Console.ReadLine());
  8. int b = int.Parse(Console.ReadLine());
  9. int c = int.Parse(Console.ReadLine());
  10. int d = int.Parse(Console.ReadLine());
  11. int e = int.Parse(Console.ReadLine());
  12.  
  13. for (int leastMajorMlt = 1; true; leastMajorMlt++)
  14. {
  15. int numCnt = 0;
  16. if (leastMajorMlt % a == 0) numCnt++;
  17. if (leastMajorMlt % b == 0) numCnt++;
  18. if (leastMajorMlt % c == 0) numCnt++;
  19. if (leastMajorMlt % d == 0) numCnt++;
  20. if (leastMajorMlt % e == 0) numCnt++;
  21. if (numCnt >= 3)
  22. {
  23. Console.WriteLine(leastMajorMlt);
  24. break;
  25. }
  26. }
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment