Divisible
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 allBasic Examples (2)
Test whether a number is divisible by :
Divisible[10, 2]The number is not divisible by :
Divisible[5, 2]Scope (6)
Divisible works over integers:
Divisible[6, 3]Gaussian integers:
Divisible[3 + I, 1 - I]Rationals:
Divisible[3 / 2, 1 / 2]Symbolic forms of numeric quantities:
Divisible[2Pi, Pi / 2]Numeric quantities:
Divisible[Sqrt[6], Sqrt[2]]Test for large integers:
Divisible[10 ^ 3000 + 1, 16001]Divisible threads elementwise over lists:
Divisible[{1, 2, 3, 4, 5, 6}, 2]TraditionalForm formatting:
Divisible[n, m]//TraditionalFormApplications (8)
Basic Applications (3)
Highlight numbers divisible by :
Multicolumn[If[Divisible[#, 3], Style[#, Red, Bold], #]& /@ Range[100], 10, ...]Generate random numbers divisible by a given number:
randomDivisible[n_, m_ : 1] := RandomChoice[Select[Range[1000], Divisible[#, n]&], m];randomDivisible[5, 10]AllTrue[%, Divisible[#, 5]&]Visualize when one number divides another:
ArrayPlot[Table[Boole[Divisible[i, j]], {i, 100}, {j, 100}]]Number Theory (5)
Recognize Wieferich primes, prime numbers p such that divides :
wprimeQ[n_] := PrimeQ[n] && (Mod[2 ^ (n - 1) - 1, n ^ 2] == 0);wprimeQ[1093]There are only two known Wieferich primes:
Select[Range[10 ^ 4], wprimeQ]Let be all numbers of the form :
hilbertQ[n_] := Divisible[n - 1, 4];
h = Select[Range[1000], hilbertQ];Check that the product of two numbers is still in :
{a, b} = RandomChoice[h, 2];
hilbertQ[a b]Recognize Hilbert primes, prime numbers that have no divisors in other than and themself:
hprimeQ[n_] := If[Length[Select[h, Divisible[n, #] && hilbertQ[n] && hilbertQ[#]&]] == 2, True, False];Find the first Hilbert primes:
Select[h, hprimeQ, 10]Find two representations of a number as the sum of two squares:
{{a, b}, {c, d}} = PowersRepresentations[377, 2, 2]Find a divisor of the number by computing the GCD of and the number:
GCD[377, a d + b c ]Divisible[377, %]Find another divisor by computing the GCD of and the number:
GCD[377, a d - b c ]Divisible[377, %]An integer is divisible by if the sum of its digits is divisible by :
Total[IntegerDigits[2895]]Divisible[2895, 3]An integer is divisible by if the alternating sum of the digits is divisible by :
Divisible[918082, 11]9 - 1 + 8 - 0 + 8 - 2is divisible by , where n is an odd integer:
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 :
{IntegerQ[10 / 2], Divisible[10, 2]}If is divisible by , then the greatest common divisor GCD of them is :
Divisible[48, 8]GCD[48, 8]If and are relatively prime, then is not divisible by :
CoprimeQ[25, 12]Divisible[25, 12]If the prime factorization of an integer has the form , then the number of its divisors is :
Part[FactorInteger[24], All, 2] + 1Times@@%Length[Divisors[24]]Use Divisors to find all divisors of an integer:
Divisors[12]Divisible[12, %]PrimeNu gives the number of distinct prime divisors:
PrimeNu[12]Divisible[12, {2, 3}]Simplify expressions:
Simplify[Divisible[b a, a], {a, b}∈Integers]Possible Issues (2)
Interactive Examples (1)
Visualize when the sum of two prime numbers is divisible by a given number:
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:
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:
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 :
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];ArrayPlot[ulam[101]Boole[Divisible[ulam[101], 9]], ColorFunction -> "Rainbow", ColorRules -> {0 -> White}]Tech Notes
Related Guides
History
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]}