Divisibility - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Number Theory: Divisibility

Getting Started

Many commands in this example worksheet are available at Maple's top level, meaning that no packages are required to be loaded. While any command in the Number Theory package can be referred to using the long form, for example, NumberTheory:-Divisors, it is often easier to load the package and then use the short form command names as well.

restart;

with(NumberTheory):

Examples

The greatest common divisor of two integers, m and n, is the largest positive integer that divides both numbers without a remainder. The top level igcd common computes the greatest common divisor of two numbers:

igcd4,10

2

(1)

igcd17,19

1

(2)

Another method for finding the gcd of two numbers is by using the extended Euclidean algorithm for integers, igcdex. This solves g = sx+ty = igcds,t.

igcdex17,19,s,t

1

(3)

s,t

9,−8

(4)

is17s+19t=1

true

(5)

The integer remainder of an integer, m, divided by n can be found using the irem command. The iquo command computes the integer quotient of m divided by n.

irem10,3

1

(6)

iquo10,3

3

(7)

If the iquo command is called with an optional third argument that specifies a name, the result for the remainder is stored in the given name. The converse is also true for the irem command:

irem28,5,quot

3

(8)

quot

5

(9)

The Divisors command from the Number Theory package returns all divisors for an integer:

Divisors6

1,2,3,6

(10)

The SumOfDivisors command returns the sum of the divisors on an integer, including the integer:

SumOfDivisors6

12

(11)

See Also

NumberTheory