There are a few optimizations you can do to reduce the amount of work you do. For the most part, it comes down to understanding the math behind the concept.
First off, if you have found the minimum common multiple for a small set of numbers to be X, then want to include another value in the set.... then the resulting minimum common multiple will be a multiple of X. Say, for example, you have the values 2, and 3, and the minimum multiple for those is 6. Now you want to find the minimum common multiple for 2, 3, and 4, then the resulting multiple 12 is also a multiple of 6. If we want to add the number 5 to the set, becoming 2, 3, 4, 5, then we know that the minimum common multiple will be a multiple of 12 too (and it is, it's 60). Taking it another step, if we add 6 to the set, well, 60 is already a multiple of 6, so there's nothing to do....
OK, so that's optimization 1.... instead of adding 20 each time, we can add the previously calculated minimum .... and now we are adding 60 already....which is 3 times faster than adding 20... throw 7 in to the mix, and the multiple is.... 420 ... which is now 21-times faster than adding 20's.
The next optimization is to do things backwards.... instead of starting from 1, start from 20....
The smallest common multiple for 20, and 19, is 380. and in to that, add 18, and the multiple is.... 3420 .... now our increments are much larger than 20....
In addition to the larger increments each time, by starting at the end you also already include lower multiples. For example, 20 is a multiple of 10, 5, 4, and 2 so when we get to those lower multiples there will be nothing to do.
Putting these two optimizations together, we end with the following code:
public static int MinMultiples(int from)
{
int multiple = from;
for (int m = from - 1; m > 1; m--)
{
int extend = multiple;
Console.WriteLine("Multiple {0} extending by {1}", m, extend);
while ((multiple % m) != 0)
{
multiple += extend;
}
}
return multiple;
}
I have put this in an Ideone here, and Ideone claims it runs in... 0.03 seconds.