WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

Divisible [n,m]

yields True if n is divisible by m, and yields False if it is not.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Applications  
Basic Applications  
Number Theory  
Properties & Relations  
Possible Issues  
Interactive Examples  
Neat Examples  
See Also
Tech Notes
Related Guides
History
Cite this Page

Divisible [n,m]

yields True if n is divisible by m, and yields False if it is not.

Details

  • Divisible is typically used to test whether n is divisible by m.
  • n is divisible by m if n is the product of m by an integer.
  • Divisible [n,m] is effectively equivalent to Mod [n,m]==0.
  • Divisible [n, m] returns False unless n and m are manifestly divisible.
  • Divisible [n,m] can be entered as .
  • can be entered as \[Divides] or divides.

Examples

open all close all

Basic Examples  (2)

Test whether a number is divisible by :

Wolfram Language code: Divisible[10, 2]

The number is not divisible by :

Wolfram Language code: Divisible[5, 2]

Scope  (6)

Divisible works over integers:

Wolfram Language code: Divisible[6, 3]

Gaussian integers:

Wolfram Language code: Divisible[3 + I, 1 - I]

Rationals:

Wolfram Language code: Divisible[3 / 2, 1 / 2]

Symbolic forms of numeric quantities:

Wolfram Language code: Divisible[2Pi, Pi / 2]

Numeric quantities:

Wolfram Language code: Divisible[Sqrt[6], Sqrt[2]]

Test for large integers:

Wolfram Language code: Divisible[10 ^ 3000 + 1, 16001]

Divisible threads elementwise over lists:

Wolfram Language code: Divisible[{1, 2, 3, 4, 5, 6}, 2]

TraditionalForm formatting:

Wolfram Language code: Divisible[n, m]//TraditionalForm

Applications  (8)

Basic Applications  (3)

Highlight numbers divisible by :

Wolfram Language code: Multicolumn[If[Divisible[#, 3], Style[#, Red, Bold], #]& /@ Range[100], 10, ...]

Generate random numbers divisible by a given number:

Wolfram Language code: randomDivisible[n_, m_ : 1] := RandomChoice[Select[Range[1000], Divisible[#, n]&], m];
Wolfram Language code: randomDivisible[5, 10]
Wolfram Language code: AllTrue[%, Divisible[#, 5]&]

Visualize when one number divides another:

Wolfram Language code: ArrayPlot[Table[Boole[Divisible[i, j]], {i, 100}, {j, 100}]]

Number Theory  (5)

Recognize Wieferich primes, prime numbers p such that divides :

Wolfram Language code: wprimeQ[n_] := PrimeQ[n] && (Mod[2 ^ (n - 1) - 1, n ^ 2] == 0);
Wolfram Language code: wprimeQ[1093]

There are only two known Wieferich primes:

Wolfram Language code: Select[Range[10 ^ 4], wprimeQ]

Let be all numbers of the form :

Wolfram Language code: hilbertQ[n_] := Divisible[n - 1, 4]; h = Select[Range[1000], hilbertQ];

Check that the product of two numbers is still in :

Wolfram Language code: {a, b} = RandomChoice[h, 2]; hilbertQ[a b]

Recognize Hilbert primes, prime numbers that have no divisors in other than and themself:

Wolfram Language code: hprimeQ[n_] := If[Length[Select[h, Divisible[n, #] && hilbertQ[n] && hilbertQ[#]&]] == 2, True, False];

Find the first Hilbert primes:

Wolfram Language code: Select[h, hprimeQ, 10]

Find two representations of a number as the sum of two squares:

Wolfram Language code: {{a, b}, {c, d}} = PowersRepresentations[377, 2, 2]

Find a divisor of the number by computing the GCD of and the number:

Wolfram Language code: GCD[377, a d + b c ]
Wolfram Language code: Divisible[377, %]

Find another divisor by computing the GCD of and the number:

Wolfram Language code: GCD[377, a d - b c ]
Wolfram Language code: Divisible[377, %]

An integer is divisible by if the sum of its digits is divisible by :

Wolfram Language code: Total[IntegerDigits[2895]]
Wolfram Language code: Divisible[2895, 3]

An integer is divisible by if the alternating sum of the digits is divisible by :

Wolfram Language code: Divisible[918082, 11]
Wolfram Language code: 9 - 1 + 8 - 0 + 8 - 2

is divisible by , where n is an odd integer:

Wolfram Language code: AllTrue[Table[4 ^ n + 5 ^ n + 6 ^ n, {n, 1, 100, 2}], Divisible[#, 15]&]

Properties & Relations  (7)

If is an integer, then is divisible by :

Wolfram Language code: {IntegerQ[10 / 2], Divisible[10, 2]}

If is divisible by , then the greatest common divisor GCD of them is :

Wolfram Language code: Divisible[48, 8]
Wolfram Language code: GCD[48, 8]

If and are relatively prime, then is not divisible by :

Wolfram Language code: CoprimeQ[25, 12]
Wolfram Language code: Divisible[25, 12]

If the prime factorization of an integer has the form , then the number of its divisors is :

Wolfram Language code: Part[FactorInteger[24], All, 2] + 1
Wolfram Language code: Times@@%
Wolfram Language code: Length[Divisors[24]]

Use Divisors to find all divisors of an integer:

Wolfram Language code: Divisors[12]
Wolfram Language code: Divisible[12, %]

PrimeNu gives the number of distinct prime divisors:

Wolfram Language code: PrimeNu[12]
Wolfram Language code: Divisible[12, {2, 3}]

Simplify expressions:

Wolfram Language code: Simplify[Divisible[b a, a], {a, b}∈Integers]

Possible Issues  (2)

With symbolic inputs, Divisible stays unevaluated:

Wolfram Language code: Divisible[x, y]

Divisible does not automatically resolve the value:

Wolfram Language code: Divisible[6(E + 1) ^ 2, 6 (1 + 2 E + E ^ 2)]
Wolfram Language code: Simplify[%]

Interactive Examples  (1)

Visualize when the sum of two prime numbers is divisible by a given number:

Wolfram Language code: Manipulate[ArrayPlot[Boole /@ Table[Divisible[Prime[m] + Prime[n], a], {m, 1, 100}, {n, 1, 100}]], {a, 3, 50, 1}]

Neat Examples  (3)

Visualize when is divisible by primes. Each row of dots corresponds to the divisors of , which are labeled along the horizontal axis:

Wolfram Language code: NumberLinePlot[Table[Select[Range[Prime[n]], (Divisible[Prime[n] - 1, #] && # > 1 && PrimeQ[#])&], {n, 1, 40}], PlotRange -> All]

Plot when divides the sum of three squares:

Wolfram Language code: ArrayMesh[Boole[Table[Divisible[a ^ 2 + b ^ 2 + c ^ 2, 5], {a, 10}, {b, 10}, {c, 10}]]]

Plot the Ulam spiral of numbers divisible by :

Wolfram Language code: ulam[n_] := Partition[Permute[Range[n ^ 2], Accumulate[Take[Flatten[{{n ^ 2 + 1} / 2, Table [(-1) ^ j i, {j, n}, {i, {-1, n}}, {j}]}], n ^ 2]]], n];
Wolfram Language code: ArrayPlot[ulam[101]Boole[Divisible[ulam[101], 9]], ColorFunction -> "Rainbow", ColorRules -> {0 -> White}]

See Also

Mod   GCD   Divisors   FactorInteger   Quotient   CoprimeQ   PrimeQ   EvenQ   Round

Wolfram Research (2007), Divisible, Wolfram Language function, https://reference.wolfram.com/language/ref/Divisible.html.

Text

Wolfram Research (2007), Divisible, Wolfram Language function, https://reference.wolfram.com/language/ref/Divisible.html.

CMS

Wolfram Language. 2007. "Divisible." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Divisible.html.

APA

Wolfram Language. (2007). Divisible. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Divisible.html

BibTeX

@misc{reference.wolfram_2026_divisible, author="Wolfram Research", title="{Divisible}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Divisible.html}", note=[Accessed: 12-June-2026]}

BibLaTeX

@online{reference.wolfram_2026_divisible, organization={Wolfram Research}, title={Divisible}, year={2007}, url={https://reference.wolfram.com/language/ref/Divisible.html}, note=[Accessed: 12-June-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /