-
MathType
-
WirisQuizzes
-
LearningLemur
-
CalcMe
-
MathPlayer
-
Store FAQ
-
VPAT for the electronic documentation
-
MathFlow
-
BF FAQ
-
Miscellaneous
-
Wiris Integrations
Arithmetic
Reading time: 3minThis section describes functions for working with numbers and their mathematical properties, including divisibility, rounding, remainders, prime numbers, rational numbers, and number formats such as decimal and hexadecimal values.
These functions are commonly used when generating or validating numerical values in exercises.
Tip: For practical examples showing how these functions are used when generating exercises, see the Examples section.
Function Reference
absolute
Description
Returns the absolute value of a number.
Syntax
absolute(Real)
Returns
The non-negative value of the given number.
decimal
Description
Returns the decimal component of a number.
Syntax
decimal(Real)
decimal(Complex)
Returns
The decimal portion of the given number.
denominator
Description
Returns the denominator of a fraction.
Syntax
denominator(Fraction)
Returns
The denominator of the input fraction.
divisors
Description
Returns the divisors of an integer.
Syntax
divisors(Integer)
divisors(Integer, Boolean)
Returns
A list containing the positive divisors of the integer in ascending order. If the optional boolean parameter is set to true, the list also includes negative divisors.
Notes
- If the boolean parameter is omitted or
false, only positive divisors are returned.
factor
Description
Returns the prime factorization of an integer.
Syntax
factor(Integer)
Returns
The decomposition of the integer into its prime factors.
floor
Description
Returns the greatest integer less than or equal to the given number.
Syntax
floor(Real)
floor(Complex)
Returns
For real numbers, the largest integer less than or equal to the input value. For complex numbers, the function is applied separately to the real and imaginary components.
Notes
- For complex inputs, the result is a complex number with floor applied to both parts.
gcd (greatest common divisor)
Description
Returns the greatest common divisor (GCD) of a set of integers or fractions.
Syntax
gcd(Integer, ..., Integer)
gcd(List)
gcd(Vector)
gcd(Fraction, Fraction)
Returns
The largest number that divides all provided values without leaving a remainder. When called with two fractions a/b and c/d, the result is the GCD defined by the system.
Notes
- For fraction inputs, this function follows the system’s fraction-GCD definition.
hexadecimal
Description
Converts a number into its hexadecimal representation.
Syntax
hexadecimal(Real)
Returns
A string containing the number represented in hexadecimal format.
Notes
- Input is interpreted as a value in base 10 and returned as a hexadecimal string.
lcm (least common multiple)
Description
Returns the least common multiple (LCM) of a set of integers or fractions.
Syntax
lcm(Integer, ..., Integer)
lcm(List)
lcm(Vector)
lcm(Fraction, Fraction)
Returns
The smallest number that is a multiple of all provided values. When called with two fractions a/b and c/d, the result is the LCM defined by the system.
Notes
- For fraction inputs, this function follows the system’s fraction-LCM definition.
mod (modulo)
Description
Computes the modulo (remainder) of a division.
Syntax
Integer mod Integer
Fraction mod Integer
Returns
For integers a and m, returns the remainder of a / m. For a fraction a/b and an integer m, returns a · b-1 mod m, as long as b is invertible modulo m.
Notes
- For fraction inputs, the denominator must be invertible modulo
m.
negative?
Description
Checks whether a number is negative.
Syntax
negative?(Real)
Returns
true if the input is negative; otherwise false.
numerator
Description
Returns the numerator of a fraction.
Syntax
numerator(Fraction)
Returns
The numerator of the input fraction.
positive?
Description
Checks whether a number is positive.
Syntax
positive?(Real)
Returns
true if the input is positive; otherwise false.
prime
Description
Returns a prime number by index.
Syntax
prime(Integer)
Returns
The n-th prime number, where n is the input integer.
Notes
- The indexing scheme (whether the first prime is
prime(1)orprime(0)) depends on the system’s definition.
prime?
Description
Checks whether an integer is prime.
Syntax
prime?(Integer)
Returns
true if the input is prime; otherwise false.
prime_power?
Description
Checks whether an integer is a prime power.
Syntax
prime_power?(Integer)
Returns
false if the input is not a prime power. If it is a prime power, returns a list with two elements: the prime base and the exponent.
Notes
- Return type is either
falseor a two-element list[prime, power].
quotient
Description
Computes the quotient of an integer division.
Syntax
quotient(Integer, Integer)
Returns
Given integers a and b (with a ≥ b), where a = q · b + r, returns the quotient q.
quotient_and_remainder
Description
Computes the quotient and remainder of an integer division.
Syntax
quotient_and_remainder(Integer, Integer)
Returns
Given integers a and b (with a ≥ b), where a = q · b + r, returns a two-element list: the quotient q and the remainder r.
rational
Description
Converts a rational value into its fraction form.
Syntax
rational(Rational)
Returns
The fraction representation of the given rational number, if possible.
rationalize
Description
Rationalizes a fraction.
Syntax
rationalize(Fraction)
Returns
A rationalized version of the input fraction, typically by simplifying and removing radicals from the denominator.
remainder
Description
Computes the remainder of an integer division.
Syntax
remainder(Integer, Integer)
Returns
Given integers a and b (with a ≥ b), where a = q · b + r, returns the remainder r.
round
Description
Rounds a number to its closest integer.
Syntax
round(Real)
round(Complex)
Returns
For real numbers, the nearest integer to the input value. For complex numbers, the function is applied separately to the real and imaginary components.
Notes
- For complex inputs, the result is a complex number with rounding applied to both parts.
sign
Description
Returns the sign of a number.
Syntax
sign(Real)
sign(Complex)
Returns
For real numbers: returns 0 if x = 0, 1 if x > 0, and -1 if x < 0.
For complex numbers: returns 0 if z = 0, and z/|z| if z ≠ 0.