Skip to content

Divisors ​

All positive divisors of n, in increasing order.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaDivisorMathWorldDivisorWikidataQ50708Encyclopedia of MathematicsDivisor_(of_an_integer_or_of_a_polynomial)Britannicatopic/divisorFungrim entry08ff0bWolfram LanguageDivisors!Rosetta CodeProper divisors
Divisors(n)all positive divisors of nn, increasing.
SageMathenumeratio_divisors(n)SymPydivisors(n)Oscarsort(divisors(ZZ(n)))Juliasort(divisors(ZZ(n)))
Divisors(n, Over -> GaussianIntegers)the first-quadrant divisors in Z[i]\mathbb{Z}[i], by real part then imaginary
Typed signatures
TypePackageApplies
(integer) -> list<integer>compute-enginealways
(number | quadratic_integer, any*) -> listnumber-theoryreplaces compute-enginealways

Domain: Number theory

Details
  • Includes both 1 and nn itself; a prime's only divisors are those two.
  • The count of divisors, d(n)d(n), equals σ0(n)\sigma_0(n). See DivisorSigma.
  • Highly composite numbers (like 720) pack unusually many divisors relative to their size.
  • compute-engine only returns ordinary positive divisors.
  • Threads element-wise over a list, as Wolfram's Listable heads do.

Examples

19 more kept as data, checked against the oracles
Basic #
live ↗
InDivisors(1 729)\mathrm{Divisors}(1\,729)Out[1,7,13,19,91,133,247,1 729]\bigl\lbrack1, 7, 13, 19, 91, 133, 247, 1\,729\bigr\rbrack
live ↗
InDivisors(20)\mathrm{Divisors}(20)Out[1,2,4,5,10,20]\bigl\lbrack1, 2, 4, 5, 10, 20\bigr\rbrack

A prime's only divisors are 1 and itself

live ↗
InDivisors(13)\mathrm{Divisors}(13)Out[1,13]\bigl\lbrack1, 13\bigr\rbrack
live ↗
InDivisors(6)\mathrm{Divisors}(6)Out[1,2,3,6]\bigl\lbrack1, 2, 3, 6\bigr\rbrack
Scope #

Threads element-wise over a list, as Wolfram's Listable heads do

live ↗
InDivisors([4,6])\mathrm{Divisors}(\bigl\lbrack4, 6\bigr\rbrack)Out[[1,2,4],[1,2,3,6]]\bigl\lbrack\bigl\lbrack1, 2, 4\bigr\rbrack, \bigl\lbrack1, 2, 3, 6\bigr\rbrack\bigr\rbrack
live ↗
InDivisors(3+4i)\mathrm{Divisors}(3+4i)Out[1,2+i,3+4i]\bigl\lbrack1, 2+i, 3+4i\bigr\rbrack

13=(2+3i)(3−2i)13 = (2 + 3i)(3 - 2i) splits, so it gains two divisors

live ↗
InDivisors(13,Rule(Over,GaussianIntegers))\mathrm{Divisors}(13, \mathrm{Rule}(\mathrm{Over}, \mathrm{GaussianIntegers}))Out[1,2+3i,3+2i,13]\bigl\lbrack1, 2+3i, 3+2i, 13\bigr\rbrack

6+4i=−i(1+i)2(3+2i)6+4i=-i(1+i)^2(3+2i)

live ↗
InDivisors(6+4i)\mathrm{Divisors}(6+4i)Out[1,1+i,1+5i,2,3+2i,6+4i]\bigl\lbrack1, 1+i, 1+5i, 2, 3+2i, 6+4i\bigr\rbrack

Listable: threads over a list

live ↗
InDivisors([605,871,824])\mathrm{Divisors}(\bigl\lbrack605, 871, 824\bigr\rbrack)Out[[1,5,11,55,121,605],[1,13,67,871],[1,2,4,8,103,206,412,824]]\bigl\lbrack\bigl\lbrack1, 5, 11, 55, 121, 605\bigr\rbrack, \bigl\lbrack1, 13, 67, 871\bigr\rbrack, \bigl\lbrack1, 2, 4, 8, 103, 206, 412, 824\bigr\rbrack\bigr\rbrack

The smallest odd prime: just 1 and 3

live ↗
InDivisors(3)\mathrm{Divisors}(3)Out[1,3]\bigl\lbrack1, 3\bigr\rbrack
Applications #

Sum of divisors of 20 not divisible by 4, scaled by 8

live ↗
In8(∑Filter(Divisors(20),_1⁡↦¬(4∣_1⁡)))8(\sum\mathrm{Filter}(\mathrm{Divisors}(20), \operatorname{\_1}↦¬(4\mid\operatorname{\_1})))Out144144
live ↗
InFilter(1..9 999,_1⁡↦∑Divisors(_1⁡)=2_1⁡)\mathrm{Filter}(1..9\,999, \operatorname{\_1}↦\sum\mathrm{Divisors}(\operatorname{\_1})=2\operatorname{\_1})OutFilter(1..9 999,_1⁡↦∑Divisors(_1⁡)=2_1⁡)\mathrm{Filter}(1..9\,999, \operatorname{\_1}↦\sum\mathrm{Divisors}(\operatorname{\_1})=2\operatorname{\_1})
Properties #

The divisor count d(n)d(n) equals σ0(n)\sigma_0(n). See DivisorSigma

live ↗
InLength(Divisors(20))=DivisorSigma(0,20)\mathrm{Length}(\mathrm{Divisors}(20))=\mathrm{DivisorSigma}(0, 20)OutTrue\mathrm{True}

Smallest prime: just 1 and 2

live ↗
InDivisors(2)\mathrm{Divisors}(2)Out[1,2]\bigl\lbrack1, 2\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

A prime square has three divisors

live ↗
InDivisors(4)\mathrm{Divisors}(4)Out[1,2,4]\bigl\lbrack1, 2, 4\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

A prime has only 1 and itself

live ↗
InDivisors(5)\mathrm{Divisors}(5)Out[1,5]\bigl\lbrack1, 5\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

A prime contributes only the trivial divisors

live ↗
InDivisors(7)\mathrm{Divisors}(7)Out[1,7]\bigl\lbrack1, 7\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

Prime cube: powers of 2 up to 8

live ↗
InDivisors(8)\mathrm{Divisors}(8)Out[1,2,4,8]\bigl\lbrack1, 2, 4, 8\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

Prime square: 1, 3, 9

live ↗
InDivisors(9)\mathrm{Divisors}(9)Out[1,3,9]\bigl\lbrack1, 3, 9\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

Product of two primes gives four divisors

live ↗
InDivisors(10)\mathrm{Divisors}(10)Out[1,2,5,10]\bigl\lbrack1, 2, 5, 10\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

11 is prime, so two divisors

live ↗
InDivisors(11)\mathrm{Divisors}(11)Out[1,11]\bigl\lbrack1, 11\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

Six divisors, listed in increasing order

live ↗
InDivisors(12)\mathrm{Divisors}(12)Out[1,2,3,4,6,12]\bigl\lbrack1, 2, 3, 4, 6, 12\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

14=2⋅714 = 2\cdot 7: each subset of primes gives a divisor

live ↗
InDivisors(14)\mathrm{Divisors}(14)Out[1,2,7,14]\bigl\lbrack1, 2, 7, 14\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

An odd semiprime, 3⋅53\cdot 5

live ↗
InDivisors(15)\mathrm{Divisors}(15)Out[1,3,5,15]\bigl\lbrack1, 3, 5, 15\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

Powers of 2 up to 16

live ↗
InDivisors(16)\mathrm{Divisors}(16)Out[1,2,4,8,16]\bigl\lbrack1, 2, 4, 8, 16\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

Two divisors mark 17 as prime

live ↗
InDivisors(17)\mathrm{Divisors}(17)Out[1,17]\bigl\lbrack1, 17\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

18=2⋅3218 = 2\cdot 3^2 has 2⋅3=62\cdot 3 = 6 divisors

live ↗
InDivisors(18)\mathrm{Divisors}(18)Out[1,2,3,6,9,18]\bigl\lbrack1, 2, 3, 6, 9, 18\bigr\rbrack

Known value · Wolfram MathematicalFunctionData, Divisors

Possible issues #

1 has exactly one divisor: itself

live ↗
InDivisors(1)\mathrm{Divisors}(1)Out[1]\bigl\lbrack1\bigr\rbrack

Only positive divisors, even for negative nn

live ↗
InDivisors(−6)\mathrm{Divisors}(-6)Out[1,2,3,6]\bigl\lbrack1, 2, 3, 6\bigr\rbrack
Neat examples #

720 is highly composite: 30 divisors, more than any smaller number

live ↗
InDivisors(720)\mathrm{Divisors}(720)Out[1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,30,36,40,45,48,60,72,80,90,120,144,180,240,360,720]\bigl\lbrack1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120, 144, 180, 240, 360, 720\bigr\rbrack
About
Examples49
Checked againstWolfram Language 48 agree1 differSageMath 37 agree1 differ1 errorSymPy 29 agree5 differ5 errormathlib4 22 agree1 differ6 errorOscar 24 agreeJulia 26 agree12 error
CrosswalkWikipediaMathWorldWikidataEncyclopedia of MathematicsBritannicaFungrim entryWolfram LanguageSageMathSymPyOscarJuliaRosetta Code

Implementation

mappedoscarpackages/oracle/src/mappings.ts
mappedsagepackages/oracle/src/mappings.ts
mappedsympypackages/oracle/src/mappings.ts

SymPy's divisors is over the integers (positive divisors of |n|); a Gaussian integer is not one, and the Over -> GaussianIntegers form has no counterpart.

mappedjuliapackages/oracle/src/mappings.ts
mappedmathlib4packages/oracle/src/mappings.ts

Nat.divisors sorted ascending into a list; natural n only, with divisors 0 = the empty list.

See also: FactorInteger, DivisorSigma