Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ggcd :: Int->Int->Int
  2.  
  3.  
  4. ggcd x y =
  5.  if (x == 0) || (y == 0) then
  6.   abs (x - y)
  7.   else
  8.    if (mod x y) == 0 then
  9.     abs y
  10.    else
  11.     ggcd y (mod x y)
  12.  
  13. is_prime :: Int->Int->Bool
  14.  
  15. is_prime x y =
  16.     if fromIntegral(y) < (sqrt $ fromIntegral(x)) then
  17.         if (mod x y) == 0
  18.             then False
  19.             else is_prime x (y + 1)
  20.     else True
  21.  
  22. prime :: Int->Bool
  23.  
  24. prime x =
  25.     if x == 0 then False
  26.         else
  27.         is_prime (abs x) 2
  28.  
  29. int_rvrs :: Int->Int->Int
  30.  
  31. int_rvrs x res=
  32.     if (x > 0)
  33.         then int_rvrs (div x 10) (res * 10 + (mod x 10))
  34.         else res
  35.  
  36. int_reverse :: Int->Int
  37.  
  38. int_reverse x =
  39.     int_rvrs x 0
  40.  
  41. ko :: Double->Double->Double->Double
  42.  
  43. ko a b c =
  44.     if a == 0
  45.         then (-c)/b
  46.         else let d = b*b - 4*a*c
  47.         in
  48.         if d >= 0
  49.             then max (((-b)+sqrt(d))/(2*a)) (((-b)-sqrt(d))/(2*a))
  50.             else error("Нет корней")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement