Fermat's little theorem
a**p =~ a (mod p)
a**p mod p = a mod p
Algorithm
# cat FermatPrimalityTest.go
# go build FermatPrimalityTest.go
# ./FermatPrimalityTest 7 1000
# carmichael_number_1=561
# carmichael_number_2=41041
# ./FermatPrimalityTest $carmichael_number_1 1000
# ./FermatPrimalityTest $carmichael_number_2 1000
References
https://en.wikipedia.org/wiki/Carmichael_number
No comments:
Post a Comment