# ClojureDocs(beta)

## Clojure Contrib

### Namespaces

• clojure.contrib
• http
• probabilities

1.2.0

# exact-integer-sqrt

## clojure.contrib.math

• (exact-integer-sqrt n)
(exact-integer-sqrt n) expects a non-negative integer n, and returns [s r] where n = s^2+r and n < (s+1)^2. In other words, it returns the floor of the square root and the 'remainder'.
For example, (exact-integer-sqrt 15) is [3 6] because 15 = 3^2+6.

### Source clojure/contrib/math.clj:206 top

```(defn exact-integer-sqrt "(exact-integer-sqrt n) expects a non-negative integer n, and returns [s r] where n = s^2+r and n < (s+1)^2.  In other words, it returns the floor of the square root and the 'remainder'.
For example, (exact-integer-sqrt 15) is [3 6] because 15 = 3^2+6."
[n]
(if (or (not (integer? n)) (neg? n))
(throw (IllegalArgumentException. "exact-integer-sqrt requires a non-negative integer"))
(let [isqrt (integer-sqrt n),
error (- n (* isqrt isqrt))]
[isqrt error])))```
Vars in clojure.contrib.math/exact-integer-sqrt: defn integer? let neg? not or
Used in 0 other vars