Professional Documents
Culture Documents
code main: mov ax,@data mov ds,ax mov al,n mov bl,r call ncr int 3
ncr proc cmp al,bl je p8 cmp bl,0 je p8 cmp bl,1 je p10 ;if r=1 then ncr=n ;if r=0 then ncr=1 ;if n=r then ncr=1
dec al cmp bl,al je p9 push ax push bx call ncr pop bx pop ax dec bl push ax push bx call ncr pop bx pop ax ret p8: inc res ret p9: p10: inc res
;(n-1)Cr ; ;
; ; ; ;(n-1)C(r-1)