Here's my submission while I'm learning Nim.
proc fac(n: int): int = if n <= 1: return 1 result = n * fac(n - 1) proc nPr(n: int, r: int): int = result = fac(n) div fac(n-r) proc `%`(n: int, r: int): int = result = nPr(n, r) proc horses(n: int): int = if n <= 3: return n result = n % 3 when isMainModule: echo horses(15) #=> 2730 echo horses(12) #=> 1320 echo horses(2) #=> 2 echo horses(11) #=> 990 # echo horses(a) #=> compiler error
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here's my submission while I'm learning Nim.