Nothing hard to do, but I thought it was entertaining while it lasted. Got this task from eulerproject.com - my solution is here ( http://pastebin.com/UZwR4P3z ), I'd really like to see how other people would attempt to do this.
(In case it's not clear - the task is to find the smallest number that is evenly divisible by all numbers from 1 to the specified range).
number gcd(number a, number b){
if( b==0 ) return a;
return gcd(b, a%b);
}
number lcm(number a, number b){
return a*b / gcd(a,b);
}
result = 1;
for(int K=1; K<=n; ++K)
result = lcm(K, result);
By the way, when calculating primes the dynamic method is awesome.
Just replace that with any output method of your liking. Visual Studio shows the return code of the program when debugging, so I didn't bother to write actual output code.