Created
September 25, 2021 22:14
-
-
Save kevduc/91d1d1e94cdd924a5bbd18d662a314d1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function y = isCarmichael(x) | |
y = false | |
if isprime(x) | |
return | |
end | |
for b = 2:x-1 | |
if gcd(b,x) ~= 1; continue; end | |
p = 1; | |
for i = 1:x-1 | |
p = mod(p*b,x); | |
end | |
if p ~= 1; return; end | |
end | |
y = true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment