]> andersk Git - moira.git/blob - util/gdss/lib/crypto/bignum/c/bzf.c
initial import of gdss from the Athena source tree
[moira.git] / util / gdss / lib / crypto / bignum / c / bzf.c
1 /* Copyright     Digital Equipment Corporation & INRIA     1988, 1989 */
2 /* Last modified_on Mon Jan 23 16:05:27 GMT+1:00 1989 by herve */
3
4 /*
5  * bzf.c: Miscellaneous functions built on top of BigZ.
6  *
7  */
8
9
10 #include "BigZ.h"
11
12                 /***************************************/
13
14 #define BzToBn(z)               ((z)->Digits)
15
16                 /***************************************/
17
18
19 BigZ BzFactorial (z)
20
21 BigZ z;
22
23 /*
24  * Returns Z!
25  * Assumes Z < Base.
26  */
27
28 {
29     BigZ        f;
30     BigNumDigit zval;
31     int         fl = 1;
32
33
34     zval = BnnGetDigit (BzToBn (z));
35     f = BzCreate (zval+1);
36     BnnSetDigit (BzToBn (f), 1);
37     BzSetSign (f, BzGetSign (z));
38
39     while (zval-- > 1) 
40     {
41         BnnMultiplyDigit (BzToBn (f), fl+1, BzToBn (f), fl, zval);
42         fl = BnnNumDigits (BzToBn (f), fl+1);
43     }
44     
45     return (f);
46 }
47
This page took 0.049703 seconds and 5 git commands to generate.