Created
September 4, 2025 15:16
-
-
Save haydenk/a206e819da15c9ebd6b019d9f460bdbb to your computer and use it in GitHub Desktop.
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
| def flexibleFizzBuzz(start: Int, end: Int) (callback: String => Unit): Unit = { | |
| for (i <- Range(start, end)) { | |
| var output: String = "" | |
| if (i % 3 == 0) { | |
| output += "Fizz" | |
| } | |
| if (i % 5 == 0) { | |
| output += "Buzz" | |
| } | |
| if (output.isEmpty) { | |
| output = s"${i}" | |
| } | |
| callback(output) | |
| } | |
| } | |
| flexibleFizzBuzz(start = 1, end = 50) { | |
| i => println(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
| 1 | |
| 2 | |
| Fizz | |
| 4 | |
| Buzz | |
| Fizz | |
| 7 | |
| 8 | |
| Fizz | |
| Buzz | |
| 11 | |
| Fizz | |
| 13 | |
| 14 | |
| FizzBuzz | |
| 16 | |
| 17 | |
| Fizz | |
| 19 | |
| Buzz | |
| Fizz | |
| 22 | |
| 23 | |
| Fizz | |
| Buzz | |
| 26 | |
| Fizz | |
| 28 | |
| 29 | |
| FizzBuzz | |
| 31 | |
| 32 | |
| Fizz | |
| 34 | |
| Buzz | |
| Fizz | |
| 37 | |
| 38 | |
| Fizz | |
| Buzz | |
| 41 | |
| Fizz | |
| 43 | |
| 44 | |
| FizzBuzz | |
| 46 | |
| 47 | |
| Fizz | |
| 49 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment