fork(3) download
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. public class Test
  5. {
  6.  
  7. public static int MinMultiples(int from)
  8. {
  9. int multiple = from;
  10. for (int m = from - 1; m > 1; m--)
  11. {
  12. int extend = multiple;
  13. Console.WriteLine("Multiple {0} extending by {1}", m, extend);
  14. while ((multiple % m) != 0)
  15. {
  16. multiple += extend;
  17. }
  18. }
  19. return multiple;
  20. }
  21.  
  22. public static void Main()
  23. {
  24. Stopwatch s = new Stopwatch();
  25. s.Start();
  26.  
  27. Console.WriteLine("Result {0}", MinMultiples(20));
  28.  
  29. s.Stop();
  30.  
  31. Console.WriteLine("The time took is {0} milliseconds.", s.ElapsedMilliseconds);
  32. }
  33. }
Success #stdin #stdout 0.03s 33952KB
stdin
Standard input is empty
stdout
Multiple 19 extending by 20
Multiple 18 extending by 380
Multiple 17 extending by 3420
Multiple 16 extending by 58140
Multiple 15 extending by 232560
Multiple 14 extending by 232560
Multiple 13 extending by 1627920
Multiple 12 extending by 21162960
Multiple 11 extending by 21162960
Multiple 10 extending by 232792560
Multiple 9 extending by 232792560
Multiple 8 extending by 232792560
Multiple 7 extending by 232792560
Multiple 6 extending by 232792560
Multiple 5 extending by 232792560
Multiple 4 extending by 232792560
Multiple 3 extending by 232792560
Multiple 2 extending by 232792560
Result 232792560
The time took is 26 milliseconds.