farey2 (a,b) (c,d) n = (p,q) where
    k = (n + b) `div` d
    p = k * c - a
    q = k * d - b
farey2 (a,b) (c,d) n = (p,q) where
    k = (n + b) `div` d
    p = k * c - a
    q = k * d - b
farey2 (a,b) (c,d) n = (p,q) where
    k = (n + b) `div` d
    p = k * c - a
    q = k * d - b