Created
November 12, 2023 11:04
-
-
Save micedreams/0d4af7c699e1e4e14bd53ddedf3249a3 to your computer and use it in GitHub Desktop.
Dart fizbuzz
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
void main() { | |
for(i=0; i<20;i++){ | |
print(fizz_buzz(i)); | |
} | |
} | |
String fizzBuzz() { | |
if (i % 3 == 0 && i % 5 == 0) { | |
return "FizzBuzz"; | |
} else if (i % 3 == 0) { | |
return "Fizz"; | |
} else if (i % 5 == 0) { | |
return "Buzz"; | |
} else { | |
return "$i"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment