Remove each prime power as soon as it is found, and stop trial division once the remaining value has no possible smaller factor:At an outer-loop boundary, write , where is the product of the prime powers already removed. The invariant states that
def divisors(n: Int): Int = {
require(n >= 1)
var remaining = n
var factor = 2
var result = 1
while (factor.toLong * factor.toLong <= remaining.toLong) {
var exponent = 0
while (remaining % factor == 0) {
remaining /= factor
exponent += 1
}
result *= exponent + 1
factor += 1
}
if (remaining > 1) result *= 2
result
}result is , every prime divisor of is smaller than factor, and remaining has no prime divisor smaller than factor. Thus if factor divides remaining, it is prime; a composite factor would have a smaller prime divisor, contrary to the invariant.During the inner loop, with fixed, . Each division removes one copy, so the positive remainder strictly decreases and supplies an inner-loop variant. On leaving the inner loop the complete power has been removed; multiplying the result by
exponent + 1 uses part (d) and reestablishes the outer invariant after advancing factor. The outer factor increases and can never exceed the original while its guard holds, proving termination.At exit, a remainder greater than one must be prime: a composite remainder would have a prime factor no larger than its square root, which would still be smaller than
factor. It therefore contributes one final factor of two. A remainder of one contributes nothing. The algorithm returns using constant auxiliary space and no array. The widened multiplication in the loop guard prevents an Int overflow in the square test. Perfect number Created 2026-10-14 Updated 2026-10-14
A perfect number is a positive integer equal to the sum of all its positive proper divisors. The divisor itself is excluded: including it gives the equivalent condition for the sum-of-divisors function. The smallest examples are and .
For comparison, has proper divisors , whose sum is : it is a deficient number. The proper divisors of are , whose sum is : it is an abundant number. The proper-divisor sum classifies these examples with the same rule, and gives , so one is not a perfect number.
Proper divisors balance a perfect number, fall short of a deficient number, or exceed an abundant number
. Original exact proper-divisor sums for . Each bar is normalized by its candidate number, and its segments are labelled with the actual proper divisors. The dashed line at one marks equality with the candidate. These are finite arithmetic calculations, not empirical data. Details.The interesting question is how such balances can be constructed without testing every smaller integer as a possible divisor. The Euclid-Euler theorem answers it for even integers: a Mersenne prime gives , and every even perfect number arises this way. For , this produces . The connection links divisor sums to primality testing for a particular family, while keeping the necessary hypotheses visible.[ref]
Euclid's Elements already gives the construction in Book IX, Proposition 36: add a succession of powers of two, and if their sum is prime, multiply by the final power of two. The modern finite geometric series makes the same pattern transparent. This original statement supplies the forward construction, rather than the converse classification of all even perfect numbers.[ref]
Perfect power Created 2026-09-24 Updated 2026-11-05
An integer is a perfect power if it can be written with integers and . In the common nontrivial positive version, both the value and the base exceed one. For example, qualifies, whereas twelve does not. The degenerate values , and are included or excluded according to the convention being used.
For a positive integer with prime factorization , the exact criterion isIf , every prime exponent is divisible by . Conversely, a common divisor lets one take . This gives a recognition test once the prime factorization is known; it does not imply that factorization is the fastest recognition algorithm.
A negative value requires an odd exponent. Thus is a perfect power, while is not: its absolute value has only powers of two as common divisors of its exponents. Perfect cubes are the special case , whereas a cube-full number imposes a different lower bound on each prime exponent.
Picard group of the projective line 2026-10-14
For any field , degree identifies the Picard group of the projective line with , generated by . A closed point on the affine chart is cut out by an irreducible polynomial , whose divisor is that point minus times infinity. Hence every divisor is linearly equivalent to its degree times infinity. Principal divisors have degree zero, so the degree map is injective as well as surjective. Thus a line bundle of degree is .
Picard scheme of a curve Created 2026-10-14 Updated 2026-11-05
For a smooth projective curve of genus over an algebraically closed field , its Picard scheme represents the sheafified Picard functor of a curve. It is a disjoint union of smooth proper schemes , indexed by the degree of a line bundle, each of dimension . Its -points are degree- line bundles up to isomorphism.[ref]
The degree-zero component is the Jacobian variety. Its group action on every degree component, by tensor product of sheaves, is free and transitive in families: degree- components are torsors rather than canonically chosen copies of the Jacobian variety. A chosen degree- line bundle supplies such an identification by tensoring. Over a general field, the same geometric components exist for a smooth projective geometrically connected curve, but they need not have a rational point, so that identification cannot be assumed over the ground field.
The construction has concrete charts: on the locus of nonspecial degree- line bundles, Riemann-Roch theorem gives one independent global section, whose zero divisor recovers the bundle. Over the algebraically closed field, translates of this open locus cover the Picard scheme.[ref]
Pollard's p-1 algorithm Created 2026-10-31 Updated 2026-11-05
For an integer to be factored, John Pollard's method chooses an integer coprime to and an exponent divisible by many small prime powers. Compute by modular exponentiation and the Euclidean algorithm. If , it is a proper divisor. If a prime divisor of has , Fermat's little theorem ensures ; success requires some other prime divisor not to divide . Common choices are and . The method exploits a smooth , rather than a small divisor itself.
Practical number 2026-10-20
A positive integer such that every positive integer at most is a sum of distinct divisors of . For example, is practical because its divisors represent every value from through .
Prime number Created 2026-09-24 Updated 2026-10-13
A prime number is a positive integer whose only positive divisors are and . The first ten prime numbers are . In contrast, is a composite number because it has a positive divisor strictly between one and itself. The integer one is neither a prime number nor a composite number: the lower bound is part of the definition. Equivalently, the divisor function satisfies for a prime number, whereas and for every composite number .
Prime numbers are the building blocks of positive integers under multiplication. The fundamental theorem of arithmetic says that every integer greater than one is a product of prime numbers, with a unique collection of factors when their order is ignored. For example, and . Their common factors reveal the greatest common divisor , and the combined maximum powers reveal the least common multiple . A complicated divisibility question becomes a comparison of prime exponents.
There is also a useful finite test. If a composite number equals with , then . Therefore some prime factor is at most , and trial division only needs to check prime numbers up to that square root. For , checking suffices; none divides , so it is a prime number. For , the same test finds , giving . To find many prime numbers together, the sieve of Eratosthenes reuses the work by marking multiples.
The division with remainder calculations for make the test explicit:Since , these are all the prime numbers at most its square root, and every remainder is nonzero. Thus the calculation certifies a prime number, without testing the integers individually. In contrast, gives a prime factor and proves that is a composite number.
The definition has a long history. Book VII of Euclid's Elements distinguishes prime numbers from composite numbers through their possible measures; Book IX, Proposition 20 establishes that no finite list exhausts the prime numbers. The modern argument under Euclid's theorem needs only divisibility, so it proves an infinite conclusion without estimating how frequently prime numbers occur. [ref]
https://mathcs.clarku.edu/~djoyce/elements/bookVII/defVII11.html. Euclid, Elements, Book VII, definitions 11–14, David Joyce's edition
[ref]https://mathcs.clarku.edu/~djoyce/elements/bookIX/propIX20.html. Euclid, Elements, Book IX, Proposition 20
. Primitive binary quadratic form Created 2026-09-24 Updated 2026-11-05
An integral binary quadratic form is primitive when . This condition concerns its polynomial coefficients, rather than the values of a particular representing pair. For example, is primitive, while has a common divisor two and represents only even integers.
Primitivity is invariant under proper equivalence. Expanding an integer change of variables expresses every new polynomial coefficient as an integer linear combination of the old ones, so every common divisor of the old coefficients divides the new ones. The integer inverse gives the converse. Their greatest common divisor, called the content, is therefore unchanged.
A primitive representation separately means in . Even a primitive form can have nonprimitive representations: for . A representation of a prime number, however, must use a coprime pair, since a common divisor would force to divide that prime. This observation drives the discriminant criterion for prime representation by a binary quadratic form.
Primitive-root lifting criterion Created 2026-09-24 Updated 2026-11-05
If is a primitive root modulo an odd prime , thenis the exact condition for to remain a primitive root modulo every power . Its multiplicative order modulo must be a multiple of and a divisor of , so the condition makes that order . The result then follows from lifting a primitive root to odd prime powers.
For example, two is primitive modulo three and . It is therefore primitive modulo every . The assumption that is odd is essential; the unit groups of higher powers of two are not cyclic groups.
Projection from a point on a plane curve Created 2026-09-29 Updated 2026-11-05
Let be an integral projective curve of degree , over an algebraically closed field, and let be a smooth point of a variety of . The pencil of plane curves of lines through initially defines a rational map . Every member has the fixed divisor . Removing that fixed divisor gives two generating global sections of the line bundle and a morphismAt , a non-tangent line vanishes to order one, so the two divided global sections do not both vanish. Elsewhere, the common zero of all lines in the pencil of plane curves would have to be . Thus the morphism is defined everywhere, even if has other singular points.
By Bézout theorem, a general line of the pencil of plane curves meets with total intersection multiplicity ; subtracting the fixed point leaves , including any inseparable contribution. For a smooth plane conic, this is a degree-one isomorphism with . If itself is a line, projection from is constant, explaining the restriction .
Riemann-Roch via elementary modifications Created 2026-10-14 Updated 2026-10-31
For a closed point on a smooth projective curve, the quotient in has -dimension . Additivity of Euler characteristic therefore changes by that residue-field degree. Every line bundle is associated with a divisor, so iteration proves the displayed formula. The dualizing sheaf on a smooth projective curve identifies with and converts this Euler-characteristic formula into the usual divisor form of Riemann-Roch theorem.
Riemann theta function Created 2026-10-14 Updated 2026-11-05
For a symmetric matrix with positive definite imaginary part, this theta function converges normally on compact subsets of . It obeys , so its zeros define a divisor on the associated complex torus. If is a curve's normalized period matrix, its zero divisor is a translate of the effective degree- locus, by the Riemann vanishing theorem. A general symmetric positive period matrix need not come from a curve.
Riemann vanishing theorem 2026-10-14
For the period matrix of a genus- compact Riemann surface, there is a vector depending on the marking and base point such that the Riemann theta function vanishes exactly on this translate of the image of the Abelian sum map. Pairing sides of the cut surface proves that a nonzero pullback has a degree- zero divisor whose Abel sum is . At a theta zero that pullback includes the base point. Irreducibility and dimension of the effective-divisor locus give equality of supports; the primitive First Chern class of the theta line bundle makes the divisor reduced.
Schinzel-Tijdeman exponent theorem Created 2026-10-14 Updated 2026-10-20
For a fixed polynomial with at least two distinct complex roots, integer solutions with and have an effectively bounded exponent. Factorization over a splitting field and the fixed differences between distinct roots control common ideal divisors. Outside a fixed set of primes, each factor's valuation is divisible by , where is its root multiplicity. The generalized power-equation estimates from linear forms in logarithms of algebraic numbers, including unit and exceptional-prime factors, give the exponent bound. A single-root polynomial and the values cannot be included: , and for , give infinite exponent families.
Selberg least-common-multiple weights Created 2026-10-06 Updated 2026-11-05
For real coefficients supported on permitted divisors up to , put . Then is an upper bound for the indicator function of numbers free of the forbidden prime factors. Its support has . If the coefficients vanish on non-squarefree integers and satisfy , then : each prime factor of occurs in , in , or in both.
Selberg sieve Created 2026-10-03 Updated 2026-11-05
The Selberg sieve constructs an upper bound for a sifting function using a square. Let be a squarefree integer, choose real weights supported on selected divisors of , and impose . ThenWhen is coprime to , the sum is exactly ; otherwise its square is nonnegative, which proves the inequality. Multiplying by nonnegative sequence weights and summing giveswhere is the least common multiple and is the weight of terms divisible by .
A sieve distribution writes . One then minimizes the main quadratic form subject to the support and normalization, while separately controlling the remainder. The Selberg sieve diagonalization explains the minimizing weights. This yields results such as the prime-tuple upper bound from the Selberg sieve, but the nonnegative-square construction by itself supplies only an upper bound.[ref]
Squarefree divisor Created 2026-10-06 Updated 2026-10-14
A squarefree divisor of an integer is a divisor that is a squarefree integer. It is specified by choosing a subset of the distinct prime factors of .
Square-free integer Created 2026-09-24 Updated 2026-11-05
A positive integer is square-free when no square number greater than one is a divisor of . It suffices to exclude squares of prime numbers; equivalently, every prime valuation is zero or one:Thus the prime factorization of a square-free integer is a product of distinct prime factors, with no repetitions. One is included: its prime factorization is an empty product and all its prime valuations are zero. These equivalent tests are stated in Grinberg's notes. [ref]
Floor and arithmetic functions by Darij Grinberg. Darij Grinberg, MIT 18.781, Floor and arithmetic functions, Definition 2.1.2 and footnote 6
For signed integers, extend the definition by requiring to be a square-free integer, where denotes absolute value. Hence and both qualify. Zero does not: every prime number has its square as a divisor of zero. The Möbius function and radical of an integer below use their existing positive integer domains, so apply them to when handling a negative integer.
For example, is a square-free integer, whereas is not, because and . Being a composite number causes no problem: are all square-free integers. A square-free integer need not be coprime to another integer: and are both square-free integers but have greatest common divisor two. In fact the only signed integers coprime to every integer are , since .
Exact square-free integer classification of the integers from one to sixty
. Green cells are square-free integers; each red cell displays a prime number square that divides its label, choosing the smallest such prime number. Only need testing in this range. There are green cells. This original finite arithmetic diagram is an exact enumeration, not a measurement or an assertion about a limiting frequency. Details.For positive integers , the useful product criterion isThe proof outline is just addition of prime valuations: can stay at most one only if neither input repeats a prime factor and no prime factor occurs in both. Thus is a square-free integer, but is not. An equivalent characterization is that every factorization into positive integers has coprime factors. If , the factorization supplies two factors sharing ; conversely, a shared prime factor forces its square to divide . For , the unordered factor pairs all have greatest common divisor one; for , the pair fails.
Two existing arithmetic functions turn the definition into practical tests:The radical of an integer keeps one copy of each prime factor, so it changes precisely the integers with a repeated prime factor. Its definition is given in Evertse's exercise sheet. [ref]
https://pub.math.leidenuniv.nl/~evertsejh/dio12-ex4.pdf. Jan-Hendrik Evertse, Diophantine approximation, Homework IV, Exercise 20
The Möbius function assigns to a square-free integer with distinct prime factors and zero otherwise; squaring forgets the sign. Consequently counts exactly the green cells. This connects a restriction on repeated prime factors with weighted counting and inclusion-exclusion. [ref]Floor and arithmetic functions by Darij Grinberg. Darij Grinberg, MIT 18.781, Definition 2.1.2: the Möbius function
Srinivasa Ramanujan 2026-11-05
Srinivasa Ramanujan developed results in number theory, including the study of highly composite numbers: positive integers having more divisors than every smaller positive integer.[ref]
His analysis connects record values of the divisor function with prime factorization. Prime exponents must be arranged in nonincreasing order as the primes increase: swapping an inverted pair would produce a smaller integer with the same divisor count, contradicting the record property. For example, has six positive divisors. The subject turns irregular arithmetic data into a constrained optimization problem.[ref]

