If you consider finding all primes under 20 to be so trivial, that it doesn't require computation, then below is an example JavaScript code (you can open your browser console and run it there), which was the only reason I choose this language for demonstration:
function euler5() {
function mul(a, b) { return a * b; }
var multipliers = [2, 3, 5, 7, 11, 13, 17, 19],
total = multipliers.reduce(mul), original, j;
for (var i = 0; i <= 20; i++) {
original = total;
j = 0;
while (original % i)
original = total * multipliers[j++];
total = original;
}
return total;
}
Trying to be more languaga-agnostic, here's the same idea in Prolog:
multiple([], X, X).
multiple([X | Xs], Acc, Result) :-
Next is X * Acc,
multiple(Xs, Next, Result).
multiple(Factors, Result) :-
multiple(Factors, 1, Result).
product_of(_, Test, _, Of, Test) :-
Mod is Test mod Of,
Mod is 0, !.
product_of(Product, Test, [X | Xs], Of, Result) :-
Mod is Test mod Of,
Mod \= 0,
Next is X * Product,
product_of(Product, Next, Xs, Of, Result).
euler5(21, _, Product, Product).
euler5(N, Factors, Product, Result) :-
product_of(Product, Product, Factors, N, Next),
N1 is N + 1,
euler5(N1, Factors, Next, Result).
euler5 :-
Factors = [2, 3, 5, 7, 11, 13, 17, 19],
multiple(Factors, Mul),
euler5(4, Factors, Mul, Result),
print(Result), nl.
The basic idea is that you first multiply all the primes and then, if the total isn't multiple of the next number, you look into your primes for the one to multiply with. Doing this in increasing order ensures that there will be no gaps which would require that you multiply by more than one prime factor at a time.
Needless to say that this runs in a tiny fraction of a second.