Created
December 19, 2012 20:12
-
-
Save kanedo/4340052 to your computer and use it in GitHub Desktop.
Fermat's little theorem
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
fermat :: (Integral i, Show i) => i -> Bool | |
fermat 1 = True -- Fermat's litte theorem only works for | |
fermat 2 = True -- numbers greater then 2 | |
fermat x = not (null [x | y<-[2.. pred x], (y^(x-1) `mod` x) == 1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment