I tested myself with MATLAB (which makes it quite easy) out of some unnecessary curiosity - it took me about seven minutes, a fair part of which was debugging.
I feel rather ashamed of that, actually.
As everyone else seems to be posting their code:
% FizzBuzz - print all numbers from 1 to 100, replacing multiples of 3 with
% "fizz", multiples of 5 with "buzz", and multiples of 3 and 5 with
% "fizzbuzz".
clear
clc
for i = 1:100
fb = '';
if length(find(factor(i)==3)) > 0
fb = [fb 'fizz'];
end
if length(find(factor(i)==5)) > 0
fb = [fb 'buzz'];
end
if length(fb) > 0
fprintf([fb '\n'])
else
fprintf('%5.0f\n', i)
end
end
A better program (by which I mean...
The Open Thread posted at the beginning of the month has exceeded 500 comments – new Open Thread posts may be made here.
This thread is for the discussion of Less Wrong topics that have not appeared in recent posts. If a discussion gets unwieldy, celebrate by turning it into a top-level post.