Skip to content

Instantly share code, notes, and snippets.

@furf
Last active August 29, 2015 14:15
Show Gist options
  • Save furf/fe2552ad702dd1916583 to your computer and use it in GitHub Desktop.
Save furf/fe2552ad702dd1916583 to your computer and use it in GitHub Desktop.
fizzbuzz
function fizzbuzz(n, s, i) {
s = {
0: 'FizzBuzz',
3: 'Fizz',
5: 'Buzz',
6: 'Fizz',
9: 'Fizz',
10: 'Buzz',
12: 'Fizz'
};
i = 0;
while (i++ < n) {
console.log(s[i % 15] || i);
}
}
fizzbuzz(100);
function fizzbuzz(n, i, f, b) {
i = 0;
while (i++ < n) {
f = i % 3 ? '' : 'Fizz';
b = i % 5 ? '' : 'Buzz';
console.log(f || b ? f + b : i);
}
}
fizzbuzz(100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment