Created
June 7, 2019 23:10
-
-
Save deech/c8f63e38215dd738cba3ac29e6980379 to your computer and use it in GitHub Desktop.
Compile Time FizzBuzz In Nim
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
import math | |
proc fizzbuzz(n: int) {.compileTime.} = | |
for i in 1 .. n: | |
let | |
by3 = (i mod 3) == 0 | |
by5 = (i mod 5) == 0 | |
if (by3 and by5): echo "FizzBuzz" | |
elif by3: echo "Fizz" | |
elif by5: echo "Buzz" | |
else: echo $i | |
static: | |
fizzbuzz 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment