This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Mod

Mod
gives the remainder on division of m by n.
Mod
uses an offset d.
  • Integer mathematical function, suitable for both symbolic and numerical manipulation.
  • For integers m and n, Mod lies between and n-1.
  • Mod gives a result in the range to n, suitable for use in functions such as Part. »
  • Mod gives a result such that and .
  • The sign of Mod is always the same as the sign of n, at least so long as m and n are both real.
  • The arguments of Mod can be any numeric quantities, not necessarily integers. »
  • For positive x, Mod gives the fractional part of x.
  • For exact numeric quantities, Mod internally uses numerical approximations to establish its result. This process can be affected by the setting of the global variable $MaxExtraPrecision.
  • Mod works with complex numbers, using its definition in terms of Quotient.
  • Mod automatically threads over lists.
Remainders mod 3:
Remainders mod 3 offset to start with 1:
Plot the sequence with fixed modulus:
Plot the sequence, varying the modulus:
Remainders mod 3:
In[1]:=
Click for copyable input
Out[1]=
 
Remainders mod 3 offset to start with 1:
In[1]:=
Click for copyable input
Out[1]=
 
Plot the sequence with fixed modulus:
In[1]:=
Click for copyable input
Out[1]=
 
Plot the sequence, varying the modulus:
In[1]:=
Click for copyable input
Out[1]=
Reduce an approximate number:
Reduce an exact numeric quantity:
Reduce mod :
Complex number:
Wilson's theorem:
Solve a modular equation:
Evaluate an integral:
Extract parts cyclically:
Select primes below 100 having the form of :
Simulate a particle bouncing in a non-commensurate box:
Define a notation for addition mod 2:
The results have the same sign as the second argument:
Expressions generated by Mod can be difficult to evaluate with machine precision:
Machine-precision numerical evaluation gives the wrong answer:
Arbitrary precision gives the correct answer:
Some computations may require higher internal precision than the default:
Binomial coefficients mod 2:
Mod 4 additive cellular automaton:
New in 1 | Last modified in 4