Skip to content

Instantly share code, notes, and snippets.

@hongsw
Last active March 22, 2023 03:19
Show Gist options
  • Save hongsw/0ff8bba5cac335f3ca769e8f2632a5ed to your computer and use it in GitHub Desktop.
Save hongsw/0ff8bba5cac335f3ca769e8f2632a5ed to your computer and use it in GitHub Desktop.
Fizz Buzz in dart (Say 'Flutter' If a multiple of 19)

Fizz Buzz in dart (Say 'Flutter' If a multiple of 19)

Created with <3 with dartpad.dev.

fizzBuzz(turn) {
var str = '';
if (turn % 3 == 0 && turn % 5 == 0){
str += 'FizzBuzz';
} else if (turn % 3 == 0) {
str += 'Fizz';
} else if (turn % 5 == 0) {
str += 'Buzz';
} if (str.isEmpty){
str = turn.toString();
}
return str;
}
main() {
for (int i = 1; i <= 36; i++){
print(fizzBuzz(i));
}
}
fizzBuzz({turn, turn_3, turn_5, turn_19}) { // fixed
var str = ''; // fixed
if (turn % 3 == 0) {
str += 'Fizz';
}
if (turn % 5 == 0) {
str += 'Buzz';
}
if (turn % 19 == 0) {
str += 'Flutter';
}
if (str.isEmpty){
str = turn.toString();
}
return str;// fixed
}// fixed
main() { // fixed
for (int i = 1; i <= 1000 ; i++){ // fixed
print(fizzBuzz(i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment