Skip to content

Instantly share code, notes, and snippets.

@deech
Created June 7, 2019 23:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deech/c8f63e38215dd738cba3ac29e6980379 to your computer and use it in GitHub Desktop.
Save deech/c8f63e38215dd738cba3ac29e6980379 to your computer and use it in GitHub Desktop.
Compile Time FizzBuzz In Nim
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