Should I be writing about Erlang?
February 1, 2007 12:21 am Erlang, Programming, TutorialsI’m becoming ever more convinced that the answer is yes. I’ve been playing, a bit, a game called Project Euler, a game for programmers wherein the object is to find solutions to deceptively simple problems. It’s surprisingly entertaining, and your score is a result of the function of programmers which have not succeeded in a task.
There are people who take long roundabout approaches to get to results like these, when instead they could be doing things like
p1() -> lists:sum(
[ X || X <- lists:seq(1,10),
((X rem 3) == 0) orelse ((X rem 5) == 0) ]
).
As a result, I’m starting to think that I need to start explaining things. Anyone agree or disagree?

February 1st, 2007 at 12:23 am
I agree 155.25471%.
you should write those tutorials you keep saying you’ll write too.
–vat
February 1st, 2007 at 12:24 am
I’ve written several already. You’ve even read a few.
August 11th, 2008 at 2:04 pm
how about this O(1) instead?
x = int((10-1)/3);
y = int((10-1)/5);
z = int((10-1)/lcm(3, 5));
(
(3 * (x * (x+1)/2)) +
(5 * (y * (y+1)/2))
) -
(lcm(3, 5) * (z * (z+1)/2))
August 11th, 2008 at 2:07 pm
Ofcourse, you can substitute any number instead of the 10 above. Like 1000, for instance, as noted in the original problem.
August 11th, 2008 at 6:53 pm
Uh. That doesn’t generate a list of numbers at all, and I don’t think there’s a way to implement lowest common multiple which is less than o(lg n), assuming that’s what lcm() is meant to be.
So, … unless I’m missing something, fail.
August 12th, 2008 at 10:31 am
You are definitely missing the most important point here, i.e. the problem in Project Euler requires you to output the sum of the numbers generated and not the numbers itself. Please read the question first: http://projecteuler.net/
August 12th, 2008 at 10:34 am
Let me list it out for you:
“If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.”