Integers

One of the most fundamental datatypes in every programming language is the integer type. &GAP; is no exception.

&GAP; integers are entered as a sequence of decimal digits optionally preceded by a + sign for positive integers or a - sign for negative integers. The size of integers in &GAP; is only limited by the amount of available memory, so you can compute with integers having thousands of digits.

gap> -1234; -1234 gap> 123456789012345678901234567890123456789012345678901234567890; 123456789012345678901234567890123456789012345678901234567890

Many more functions that are mainly related to the prime residue group of integers modulo an integer are described in chapter , and functions dealing with combinatorics can be found in chapter .

Integers: Global Variables
<#Include Label="IntegersGlobalVars"> <#Include Label="IsIntegers">

Elementary Operations for Integers
<#Include Label="IsInt"> <#Include Label="IsPosInt"> <#Include Label="Int"> <#Include Label="IsEvenInt"> <#Include Label="IsOddInt"> <#Include Label="AbsInt"> <#Include Label="SignInt"> <#Include Label="LogInt"> <#Include Label="RootInt"> <#Include Label="SmallestRootInt"> <#Include Label="ListOfDigits">

for integers returns pseudo random integers between -10 and 10 distributed according to a binomial distribution. To generate uniformly distributed integers from a range, use the construction Random( [ low .. high ] ) (see ).
Quotients and Remainders
<#Include Label="QuoInt"> <#Include Label="BestQuoInt"> <#Include Label="RemInt"> <#Include Label="GcdInt"> <#Include Label="Gcdex"> <#Include Label="LcmInt"> <#Include Label="CoefficientsQadic"> <#Include Label="CoefficientsMultiadic"> <#Include Label="ChineseRem"> <#Include Label="PowerModInt">

Prime Integers and Factorization
<#Include Label="Primes"> <#Include Label="IsPrimeInt"> <#Include Label="PrimalityProof"> <#Include Label="IsPrimePowerInt"> <#Include Label="NextPrimeInt"> <#Include Label="PrevPrimeInt"> <#Include Label="FactorsInt"> <#Include Label="PrimeDivisors"> <#Include Label="PartialFactorization"> <#Include Label="PrintFactorsInt"> <#Include Label="PrimePowersInt"> <#Include Label="DivisorsInt">

Residue Class Rings
mod
modulo
returns a residue class ring of modulo an ideal. These residue class rings are rings, thus all operations for rings (see Chapter ) apply. See also Chapters and .

If r, s and n are integers, r / s as a reduced fraction is p/q, where q and n are coprime, then r / s mod n is defined to be the product of p and the inverse of q modulo n. See Section for more details and definitions.

With the above definition, 4 / 6 mod 32 equals 2 / 3 mod 32 and hence exists (and is equal to 22), despite the fact that 6 has no inverse modulo 32.
<#Include Label="ZmodnZ"> <#Include Label="ZmodnZObj"> <#Include Label="IsZmodnZObj">

Check Digits
<#Include Label="CheckDigitISBN"> <#Include Label="CheckDigitTestFunction">

Random Sources

&GAP; provides methods for many collections of objects. On a lower level these methods use random sources which provide random integers and random choices from lists.

<#Include Label="IsRandomSource"> <#Include Label="Random"> <#Include Label="State"> <#Include Label="IsGlobalRandomSource"> <#Include Label="RandomSource">