Skip to content

Instantly share code, notes, and snippets.

@thara
Created December 11, 2012 13:04
Show Gist options
  • Save thara/4258421 to your computer and use it in GitHub Desktop.
Save thara/4258421 to your computer and use it in GitHub Desktop.
FizzBuzz - functional -
var limit = 100;
fizz(i) => i % 3 == 0 ? "Fizz" : "";
buzz(i) => i % 5 == 0 ? "Buzz" : "";
for (var i = 1; i <= limit; i++) {
var sb = new StringBuffer().add(fizz(i)).add(buzz(i));
print(sb.isEmpty ? "${i}" : sb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment