Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Multifactorial/Nim/multifactorial.nim
Normal file
17
Task/Multifactorial/Nim/multifactorial.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Recursive
|
||||
proc multifact(n, deg: int): int =
|
||||
result = (if n <= deg: n else: n * multifact(n - deg, deg))
|
||||
|
||||
# Iterative
|
||||
proc multifactI(n, deg: int): int =
|
||||
result = n
|
||||
var n = n
|
||||
while n >= deg + 1:
|
||||
result *= n - deg
|
||||
n -= deg
|
||||
|
||||
for i in 1..5:
|
||||
stdout.write "Degree ", i, ": "
|
||||
for j in 1..10:
|
||||
stdout.write multifactI(j, i), " "
|
||||
stdout.write('\n')
|
||||
Loading…
Add table
Add a link
Reference in a new issue