X-Git-Url: http://git.thejh.net/?p=tools.git;a=blobdiff_plain;f=math%2Feea.c;fp=math%2Feea.c;h=4e05494069c1b36f5b6061044786b166444b8db2;hp=0000000000000000000000000000000000000000;hb=847df72c4f2e266c86c37193751e1ec0d8435293;hpb=384ee75e98daccfb078ee084edfdfa0b3188b79e diff --git a/math/eea.c b/math/eea.c new file mode 100644 index 0000000..4e05494 --- /dev/null +++ b/math/eea.c @@ -0,0 +1,35 @@ +#include +#include +#include + +#define num long long + +num mod_inverse(num n, num p) { + assert(n>=0); + assert(n

"), exit(1); + num n = strtoll(argv[1], NULL, 0); + num p = strtoll(argv[2], NULL, 0); + if (n >= p || n < 0 || p <= 0) puts("bad input"), exit(1); + printf("%lld\n", mod_inverse(n, p)); + return 0; +} \ No newline at end of file