Created
January 5, 2019 22:36
-
-
Save mirez/8b0c3782f8ce769b1e04a7a93a0938c3 to your computer and use it in GitHub Desktop.
returns true if the integer is prime and a palindrome
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
divides d n = rem n d == 0 | |
ldf k n | divides k n = k | |
| k^2 > n = n | |
| otherwise = ldf (k+1) n | |
ld n = ldf 2 n | |
prime0 n | n < 1 = error "not a positive integer" | |
| n == 1 = False | |
| otherwise = ld n == n | |
pp n = (show n == reverse (show n) ) && prime0 n | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment