Created
November 27, 2024 06:31
-
-
Save denisdemaisbr/83da2052f24a7c30427d392498fd45d9 to your computer and use it in GitHub Desktop.
modular multiplication in c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
gcc --ffast-math -std=c99 -o modmul modmul.c -lm | |
./modmul | |
(2 x 3) mod 6 = 0 | |
*/ | |
#include <stdio.h> | |
int modular_multiplication(int a, int b, int m) { | |
return (a * b) % m; | |
} | |
int main(void) { | |
int a = 2, b = 3, m = 6; | |
int result = modular_multiplication(a, b, m); | |
printf("(%d x %d) mod %d = %d\n", a, b, m, result); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment