X-Git-Url: http://git.thejh.net/?p=tools.git;a=blobdiff_plain;f=math%2Fordnung.c;fp=math%2Fordnung.c;h=c49e8937c2bb1d83f09de29d2492fed818d4a829;hp=0000000000000000000000000000000000000000;hb=7ebc44a8d838298394178687975cf9d2994ff8be;hpb=86973028b439986f4b2a7722c92e44c643ff5869 diff --git a/math/ordnung.c b/math/ordnung.c new file mode 100644 index 0000000..c49e893 --- /dev/null +++ b/math/ordnung.c @@ -0,0 +1,18 @@ +#include +#include + +int main(int argc, char **argv) { + if (argc != 3) puts("invocation:

"), exit(1); + int p = atoi(argv[1]); + int a = atoi(argv[2]); + + int n = a; + int order = 1; + while (n != 1) { + n = (((long long)n) * a) % p; + order++; + } + + printf("Die Ordnung ist %d.%s\n", order, (order==p-1)?" Primitives Element":""); + return 0; +}