Created
March 21, 2013 02:16
-
-
Save xumingming/5210213 to your computer and use it in GitHub Desktop.
求解一元二次方程
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So nostalgic...