Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
26
Task/Left-factorials/Nim/left-factorials.nim
Normal file
26
Task/Left-factorials/Nim/left-factorials.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import iterutils, bigints
|
||||
|
||||
proc lfact: iterator: BigInt =
|
||||
result = iterator: BigInt =
|
||||
yield 0.initBigInt
|
||||
var
|
||||
fact = 1.initBigInt
|
||||
sum = 0.initBigInt
|
||||
n = 1.initBigInt
|
||||
while true:
|
||||
sum += fact
|
||||
fact *= n
|
||||
n += 1
|
||||
yield sum
|
||||
|
||||
echo "first 11:\n "
|
||||
for i in lfact().slice(last = 10):
|
||||
echo " ", i
|
||||
|
||||
echo "20 through 110 (inclusive) by tens:"
|
||||
for i in lfact().slice(20, 110, 10):
|
||||
echo " ", i
|
||||
|
||||
echo "Digits in 1,000 through 10,000 (inclusive) by thousands:"
|
||||
for i in lfact().slice(1_000, 10_000, 1_000):
|
||||
echo " ", ($i).len
|
||||
Loading…
Add table
Add a link
Reference in a new issue