Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,15 @@
: fact ( n -- n-factorial )
dup 0 = [ drop 1 ] [ dup 1 - fact * ] if ;
: choose ( n k -- n-choose-k )
2dup - [ fact ] tri@ * / ;
! outputs 10
5 3 choose .
! alternative using folds
USE: math.ranges
! (product [n..k+1] / product [n-k..1])
: choose-fold ( n k -- n-choose-k )
2dup 1 + [a,b] product -rot - 1 [a,b] product / ;