File: modular_arithmetic_example.c

package info (click to toggle)
liquid-dsp 1.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,216 kB
  • sloc: ansic: 115,859; sh: 3,513; makefile: 1,350; python: 274; asm: 11
file content (35 lines) | stat: -rw-r--r-- 819 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// modular_arithmetic_example.c
//
// This example demonstrates some modular arithmetic functions.
//

#include <stdio.h>
#include "liquid.h"

int main() {
    unsigned int n=280;
    unsigned int factors[LIQUID_MAX_FACTORS];
    unsigned int num_factors=0;

    // compute factors of n
    liquid_factor(n,factors,&num_factors);
    printf("factors of %u:\n", n);
    unsigned int i;
    for (i=0; i<num_factors; i++)
        printf("%3u\n", factors[i]);
    
    // compute unique factors
    liquid_unique_factor(n,factors,&num_factors);
    printf("unique factors of %u:\n", n);
    for (i=0; i<num_factors; i++)
        printf("%3u\n", factors[i]);

    // compute Euler's totient function
    unsigned int t = liquid_totient(n);
    printf("totient(%u) = %u\n", n, t);

    printf("done.\n");
    return 0;
}