Skip to content

Instantly share code, notes, and snippets.

@xumingming
Created March 21, 2013 02:16
Show Gist options
  • Save xumingming/5210213 to your computer and use it in GitHub Desktop.
Save xumingming/5210213 to your computer and use it in GitHub Desktop.
求解一元二次方程
(defn resolve-formula [a b c]
(let [m (- (Math/pow b 2) (* 4 a c))]
(if (>= m 0)
(let [sqrt-m (Math/sqrt m)
minus-b (- 0 b)
a-2 (* 2 a)]
[(/ (+ minus-b sqrt-m) a-2) (/ (- minus-b sqrt-m) a-2)])
[nil nil])))
@hyper0x
Copy link

hyper0x commented Mar 21, 2013

So nostalgic...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment