Advertisement
PonaFly

Untitled

Nov 4th, 2019
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- 3 задача из хаск.1
  2. myiter :: Int -> Int -> Bool
  3. myiter a b =  
  4.  if a >= b
  5.   then False
  6.   else (if mod b a  == 0
  7.      then True
  8.      else myiter (a+1) b)
  9. isPrime :: Int -> Bool
  10. isPrime 1 = False
  11. isPrime 0 = False
  12. isPrime a = not (myiter 2 a)
  13. --5 задача из хаск.1
  14. maxRoot :: Int -> Int -> Int -> Double
  15. maxRoot a b c =
  16.  if (b^2 - 4*a*c) < 0
  17.   then 0/0
  18.   else (if (b^2 - 4*a*c) == 0
  19.           then ( (-b)/(2*a))
  20.           else (max((((-b)+(sqrt(b^2 - 4*a*c)))/(2*a)) (((-b)-(sqrt(b^2 - 4*a*c)))/(2*a))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement