# Module arithmetic

`:- use_module(library(arithmetic)).`

Arithmetic predicates

These predicates are additions to standard the arithmetic functions provided by `is/2`

.

#### expmod(+Base, +Expo, +Mod, -R).

Modular exponentiation. Base, Expo and Mod must be integers.

#### lcm(+A, +B, -Lcm) is det.

Calculates the Least common multiple for A and B: the smallest positive integer that is divisible by both A and B.

A and B need to be integers.

#### lsb(+X, -N).

True iff N is the least significat bit of integer X

#### msb(+X, -N).

True iff N is the most significant bit of integer X

#### number_to_rational(+Real, -Fraction).

True iff given a number Real, Fraction is the same number represented as a fraction.

#### rational_numerator_denominator(+Fraction, -Numerator, -Denominator).

True iff given a fraction Fraction, Numerator is the numerator of that fraction and Denominator the denominator.

#### popcount(+Number, -Bits1).

True iff given an integer Number, Bits1 is the amount of 1 bits the binary representation of that number has.