XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

gcd


Type:   -   function (subr)
Source:   -   xlmath.c

Syntax

(gcd [int ... ])
int - an integer expression
returns - the greatest common divisor

Description

The 'gcd' function returns the greatest common divisor of a series of integers. If no arguments are given, a zero is returned. If only one argument is given, the absolute value of the argument is returned. The successful result is always a positive integer.

Examples

(gcd 51 34)       ; returns 17
(gcd 99 66 22)    ; returns 11
(gcd -99 66 -33)  ; returns 33
(gcd -14)         ; returns 14
(gcd 0)           ; returns 0
(gcd)             ; returns 0
(gcd .2)          ; error: bad argument type - 0.2

See the gcd function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next