diff --git a/basis/math/combinatorics/combinatorics-tests.factor b/basis/math/combinatorics/combinatorics-tests.factor index ac0933fdbe..4e61f27f0d 100644 --- a/basis/math/combinatorics/combinatorics-tests.factor +++ b/basis/math/combinatorics/combinatorics-tests.factor @@ -1,6 +1,7 @@ USING: kernel math math.combinatorics math.combinatorics.private tools.test sequences ; IN: math.combinatorics.tests +[ 1 ] [ -1 factorial ] unit-test ! required by other math.combinatorics words [ 1 ] [ 0 factorial ] unit-test [ 1 ] [ 1 factorial ] unit-test [ 3628800 ] [ 10 factorial ] unit-test diff --git a/basis/math/combinatorics/combinatorics.factor b/basis/math/combinatorics/combinatorics.factor index 4f4a20d478..c9bf5c6bf5 100644 --- a/basis/math/combinatorics/combinatorics.factor +++ b/basis/math/combinatorics/combinatorics.factor @@ -18,7 +18,7 @@ IN: math.combinatorics PRIVATE> : factorial ( n -- n! ) - iota 1 [ 1 + * ] reduce ; + dup 1 > [ [1,b] product ] [ drop 1 ] if ; : nPk ( n k -- nPk ) 2dup possible? [ dupd - [a,b) product ] [ 2drop 0 ] if ;