A < 140 byte solution to the classic "FizzBuzz" problem.
The Fizz Buzz problem I'll work with is defined as follows:
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz.” For numbers which are multiples of both three and five print “FizzBuzz.”
For more information, see the page at http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html.
@danbeam on Twitter previously solved this problem in 84 Bytes. His solution was as follows:
for(i=0;++i<101;)console.log(!(i%15)&&"fizzbuzz"||!(i%3)&&"fizz"||!(i%5)&&"buzz"||i)
My solution solves it in 67. Beat that, ninja's :)
No problem.
Yes it does count. If you don't want to leak, use a
var
statement, or abuse anargument
of the function.