Created with <3 with dartpad.dev.
Last active
March 22, 2023 03:19
-
-
Save hongsw/0ff8bba5cac335f3ca769e8f2632a5ed to your computer and use it in GitHub Desktop.
Fizz Buzz in dart (Say 'Flutter' If a multiple of 19)
This file contains hidden or 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
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)); | |
} | |
} |
This file contains hidden or 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
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