Paste: n over k (choose)

Author: randy
Mode: factor
Date: Wed, 1 Jul 2009 14:36:17
Plain Text |
USING: io kernel math math.order math.ranges sequences ;
IN: golf-choose

: nk-choose ( n-up k-down -- x )
    2dup swap [ 0 ] dip between?
    [
        2dup - rot (a,b] 
        swap 1 max [1,b] 
        1 [ / * ] 2reduce
    ]
    [ 2drop 0 ] if ; 

New Annotation

Summary:
Author:
Mode:
Body: