Created
October 10, 2011 18:30
-
-
Save gardejo/1276108 to your computer and use it in GitHub Desktop.
Fizz Buzz on Dart (1)
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
// fizz_buzz.dart | |
// http://try-dart-lang.appspot.com/s/nI4R | |
main() { | |
String fizz = 'Fizz'; | |
String buzz = 'Buzz'; | |
for (int number = 1; number <= 100; number ++) { | |
bool is_fizz = number % 3 == 0; | |
bool is_buzz = number % 5 == 0; | |
print( | |
is_fizz && is_buzz ? fizz + buzz | |
: is_fizz ? fizz | |
: is_buzz ? buzz | |
: number | |
); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment