CNP

Contents


cnp calculates the number (N) of combinations of OBJects used from P to P.

 

Syntax

   cnp(n, p)

 

Parameters

Element

Description

Restrictions

n

Whole Number

0 <= n < 2^31

p

Whole Number

0 <= p <= n

 

Examples

NBCOMB = cnp(N*2, len(C))
SOMPUIS = sigma(I=0, N, cnp(N,I) * X^I * Y^(N-I))

 

Description and Comments

cnp(N,P) returns fac(N) / (fac(P) * fac(N-P)).

So as not to lose any precision in the calculation, Adonix does not use the fac function, which allows for extended domains of use for (n, p).

cnp truncates n and p if they are not whole numbers.

The result is one of the following types:

·         Integer if cnp(n, p) < 2^31-1

·         Otherwise, Decimal

Associated Errors

Error

Description

ERHUGE (13)

Capacity exceeded during the calculation

ERDOM (50)

Domain error (n<0, p<0, or n<p).

 

Associated Keywords

FAC - ANP


CONTENTS


Copyright © Sage 1999 - 2007