# chickadee » scheme » modulo

##### Identifier search
(quotient n n)procedure
(remainder n n)procedure
(modulo n n)procedure

These procedures implement number-theoretic (integer) division. n should be non-zero. All three procedures return integers. If n/n is an integer:

```   (quotient n n)           ===> n/n
(remainder n n)          ===> 0
(modulo n n)             ===> 0```

If n/n is not an integer:

```   (quotient n n)           ===> n[q]
(remainder n n)          ===> n[r]
(modulo n n)             ===> n[m]```

where n[q] is n/n rounded towards zero, 0 < |n[r]| < |n|, 0 < |n[m]| < |n|, n[r] and n[m] differ from n by a multiple of n, n[r] has the same sign as n, and n[m] has the same sign as n.

From this we can conclude that for integers n and n with n not equal to 0,

```    (= n (+ (* n (quotient n n))
(remainder n n)))
===>  #t```

provided all numbers involved in that computation are exact.

```(modulo 13 4)                   ===>  1
(remainder 13 4)                ===>  1

(modulo -13 4)                  ===>  3
(remainder -13 4)               ===>  -1

(modulo 13 -4)                  ===>  -3
(remainder 13 -4)               ===>  1

(modulo -13 -4)                 ===>  -1
(remainder -13 -4)              ===>  -1

(remainder -13 -4.0)            ===>  -1.0  ; inexact```