Created
December 11, 2012 13:04
-
-
Save thara/4258421 to your computer and use it in GitHub Desktop.
FizzBuzz - functional -
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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