Last active
October 3, 2018 23:17
-
-
Save ordovician/8356480 to your computer and use it in GitHub Desktop.
[CongruenceModulo] Functions I made for solving problems in the Khan Academy excercises on Congruence Modulo. Usefull stuff to understand when learning about cryptograpy, like the RSA algorithm used in SSL/TSL as used in HTTPS. If two values A and B gives the same result when doing mod(A, C) and mod(B, C) then they are in the same equivalence cl…
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
# check if A is congruent to B modulo C. | |
in_same_equivalence_class(A, B, C) = mod(A, C) == mod(B, C) | |
# find all X in Xs where X is congruent to B modulo C | |
function find_numbers_in_same_equivalence_class(A, C, Xs) | |
r = mod(A, C) | |
filter(X->mod(X,C) == r, Xs) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment