projects
/
tools.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
add a few more tools. most useful: round.c
[tools.git]
/
math
/
ordnung.c
1
#include <stdlib.h>
2
#include <stdio.h>
3
4
int main(int argc, char **argv) {
5
if (argc != 3) puts("invocation: <p> <a>"), exit(1);
6
int p = atoi(argv[1]);
7
int a = atoi(argv[2]);
8
9
int n = a;
10
int order = 1;
11
while (n != 1) {
12
n = (((long long)n) * a) % p;
13
order++;
14
}
15
16
printf("Die Ordnung ist %d.%s\n", order, (order==p-1)?" Primitives Element":"");
17
return 0;
18
}