/* $Id: t_bdCombinatorics.c $ */
/*
* Copyright (C) 2026 David Ireland, D.I. Management Services Pty Limited
* <https://di-mgt.com.au/contact/> <https://di-mgt.com.au/bigdigits.html>
* SPDX-License-Identifier: MPL-2.0
*
* Last updated:
* $Date: 2026-03-30 00:29:00 $
* $Revision: 1.0.1 $
* $Author: dai $
*/
#include <stdio.h>
#include "bigd.h"
#include "bdcombinatorics.h"
/*
To compile, have the following files in your path
- t_bdCombinatorics.c
- bdcombinatorics.c
- bdcombinatorics.h
- bigd.c
- bigd.h
- bigdigits.c
- bigdigits.h
- bigdtypes.h
Using MSVC command line
`CL /TC t_bdCombinatorics.c bdcombinatorics.c bigd.c bigdigits.c /link user32.lib /Fe:t_bdCombinatorics.exe`
or, to avoid linking to Windows GUI user32.lib (new in [v2.7]), use NO_WINGUI macro
`CL /TC /DNO_WINGUI t_bdCombinatorics.c bdcombinatorics.c bigd.c bigdigits.c /Fe:t_bdCombinatorics.exe`
*/
int main(void)
{
printf("bdVersion=%d Compiled: %s\n", bdVersion(), bdCompileTime());
if (bdVersion() < 2700) {
printf("ERROR: require bigd version 2.7 or later\n");
return 1;
}
// Three examples
{
BIGD result;
result = bdNew();
bd_factorial(result, 52);
bdPrintDecimal("", result, "\n");
// 80658175170943878571660636856403766975289505440883277824000000000000
bdFree(&result);
}
{
BIGD result;
result = bdNew();
bd_binomial(result, 52, 13);
bdPrintDecimal("", result, "\n");
// 635013559600
bdFree(&result);
}
{
BIGD result;
result = bdNew();
bd_permutations(result, 52, 13);
bdPrintDecimal("", result, "\n");
// 3954242643911239680000
bdFree(&result);
}
return 0;
}