Nim
Nim
Installation
Ubuntu
apt install nim
Arch Linux
pacman -S nim
Binary
# Download nim-{version}-{os}_{arch}.tar.xz from https://nim-lang.org/
tar xJf nim-{version}-{os}_{arch}.tar.xz
cd nim-{version}
sh ./install.sh /usr/local
export PATH=/usr/local/nim/bin:$PATH
Examples
Fibonacci Numbers
# Fibonacci Numbers
import os
import strutils
proc fib(n: int): int =
if n < 2:
return n
else:
return fib(n - 2) + fib(n - 1)
var n = parseInt(paramStr(1))
echo(fib(n))
discard """
example
compile:
nim compile --opt:[none|speed|size] -d:release fib.nim
run:
./fib 39
"""