Skip to content

Instantly share code, notes, and snippets.

@airicbear
Created March 4, 2021 14:17
Show Gist options
  • Save airicbear/7fcda05db9f89febe8fc70b0c986ec49 to your computer and use it in GitHub Desktop.
Save airicbear/7fcda05db9f89febe8fc70b0c986ec49 to your computer and use it in GitHub Desktop.
Inverse modulo implementation
# Note that Julia has a built-in invmod function already
function myinvmod(A, C)
for B ∈ 0:(C-1)
if mod(A*B, C) == 1
return B
end
end
return A
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment