1 //
2 // modular_arithmetic_example.c
3 //
4 // This example demonstates some modular arithmetic functions.
5 //
6
7 #include <stdio.h>
8 #include "liquid.h"
9
main()10 int main() {
11 unsigned int n=280;
12 unsigned int factors[LIQUID_MAX_FACTORS];
13 unsigned int num_factors=0;
14
15 // compute factors of n
16 liquid_factor(n,factors,&num_factors);
17 printf("factors of %u:\n", n);
18 unsigned int i;
19 for (i=0; i<num_factors; i++)
20 printf("%3u\n", factors[i]);
21
22 // compute unique factors
23 liquid_unique_factor(n,factors,&num_factors);
24 printf("unique factors of %u:\n", n);
25 for (i=0; i<num_factors; i++)
26 printf("%3u\n", factors[i]);
27
28 // compute Euler's totient function
29 unsigned int t = liquid_totient(n);
30 printf("totient(%u) = %u\n", n, t);
31
32 printf("done.\n");
33 return 0;
34 }
35
36