Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Factorions/Factor/factorions.factor
Normal file
16
Task/Factorions/Factor/factorions.factor
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
USING: formatting io kernel math math.parser math.ranges memoize
|
||||
prettyprint sequences ;
|
||||
IN: rosetta-code.factorions
|
||||
|
||||
! Memoize factorial function
|
||||
MEMO: factorial ( n -- n! ) [ 1 ] [ [1,b] product ] if-zero ;
|
||||
|
||||
: factorion? ( n base -- ? )
|
||||
dupd >base string>digits [ factorial ] map-sum = ;
|
||||
|
||||
: show-factorions ( limit base -- )
|
||||
dup "The factorions for base %d are:\n" printf
|
||||
[ [1,b) ] dip [ dupd factorion? [ pprint bl ] [ drop ] if ]
|
||||
curry each nl ;
|
||||
|
||||
1,500,000 9 12 [a,b] [ show-factorions nl ] with each
|
||||
Loading…
Add table
Add a link
Reference in a new issue