RosettaCodeData/Task/Left-factorials/Bracmat/left-factorials.bracmat
2015-02-20 09:02:09 -05:00

37 lines
734 B
Text

( ( leftFact
= result factorial i
. 0:?result
& 1:?factorial
& 0:?i
& whl
' ( !i+1:~>!arg:?i
& !factorial+!result:?result
& !factorial*!i:?factorial
)
& !result
)
& ( iterate
= from to step c fun
. !arg:(?from.?to.?step.?fun)
& !from+-1*!step:?from
& !step:?c
& whl
' ( !step+!from:~>!to:?from
& !fun$(leftFact$!from)
)
&
)
& out$"First 11 left factorials:"
& iterate$(0.10.1.out)
& out$"
20 through 110 (inclusive) by tens:"
& iterate$(20.110.10.out)
& out$"
Digits in 1,000 through 10,000 by thousands:"
& iterate
$ ( 1000
. 10000
. 1000
. (=L.@(!arg:? [?L)&out$!L)
)
)