Advertisement
Manioc

primes

Oct 5th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. isPrim::Int->Int->Int
  3. isPrim x y
  4.             | x == y = 1
  5.             | (x `mod` y) == 0 = 0
  6.             | otherwise = (isPrim x (y+1))
  7.  
  8. qnt::String->Int->Int
  9. qnt s t
  10.     | t == (length s) = (isPrim (read s::Int) 1)
  11.     | otherwise = (isPrim (read s::Int) 1) + (qnt s (t+1))
  12.  
  13. percorre::String->Int
  14. percorre (f:r) = (qnt r 0) + (percorre r)
  15.  
  16. main::IO()
  17.  
  18. main = do
  19.     pal <- getLine
  20.     putStrLn( show((percorre pal) + (percorre (reverse pal))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement