Skip to content

Instantly share code, notes, and snippets.

@mirez
Created January 5, 2019 22:36
Show Gist options
  • Save mirez/8b0c3782f8ce769b1e04a7a93a0938c3 to your computer and use it in GitHub Desktop.
Save mirez/8b0c3782f8ce769b1e04a7a93a0938c3 to your computer and use it in GitHub Desktop.
returns true if the integer is prime and a palindrome
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