Next: , Previous: Number Syntax, Up: Numbers


5.5.2.7 Operations on Integer Values

— Scheme Procedure: odd? n
— C Function: scm_odd_p (n)

Return #t if n is an odd number, #f otherwise.

— Scheme Procedure: even? n
— C Function: scm_even_p (n)

Return #t if n is an even number, #f otherwise.

— Scheme Procedure: quotient n d
— Scheme Procedure: remainder n d
— C Function: scm_quotient (n, d)
— C Function: scm_remainder (n, d)

Return the quotient or remainder from n divided by d. The quotient is rounded towards zero, and the remainder will have the same sign as n. In all cases quotient and remainder satisfy n = q*d + r.

          (remainder 13 4) => 1
          (remainder -13 4) => -1
     
— Scheme Procedure: modulo n d
— C Function: scm_modulo (n, d)

Return the remainder from n divided by d, with the same sign as d.

          (modulo 13 4) => 1
          (modulo -13 4) => 3
          (modulo 13 -4) => -3
          (modulo -13 -4) => -1
     
— Scheme Procedure: gcd x...
— C Function: scm_gcd (x, y)

Return the greatest common divisor of all arguments. If called without arguments, 0 is returned.

The C function scm_gcd always takes two arguments, while the Scheme function can take an arbitrary number.

— Scheme Procedure: lcm x...
— C Function: scm_lcm (x, y)

Return the least common multiple of the arguments. If called without arguments, 1 is returned.

The C function scm_lcm always takes two arguments, while the Scheme function can take an arbitrary number.

— Scheme Procedure: modulo-expt n k m
— C Function: scm_modulo_expt (n, k, m)

Return n raised to the integer exponent k, modulo m.

          (modulo-expt 2 3 5)
             => 3