GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
xt_n_choose_k(3) FreeBSD Library Functions Manual xt_n_choose_k(3)

#include <xtend/math.h>
-lxtend

#include <stdint.h>
#include "math.h"
unsigned long   xt_n_choose_k(unsigned long n, unsigned long k)

n   Number of items to choose from
k   Number of items chosen

Compute the binomial coefficient N choose K = N! / (K! * (N-K)!). This represents the number of ways to choose K items out of a pool of N, such that we don't care about order. E.g., if choosing 2 letters from the set [A B C D E], [C D] is considered the same [D C].

This implementation avoids overflow by alternating multiply and divide operations (rather than try to compute factorials first, which will fail for relatively small values of N or K).

The number of ways to choose K items from N objects.

#include <xtend/math.h>
unsigned long   n = 5, k = 2;
printf("Ways to choose %lu items from %lu = %lun",
        k, n, xt_binomial(n, k));

lgamma(3)


Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.