Sum of Prime Factors Calculator (sopf)

Number Theory

Sum of prime factors sopf(n)10
Factorisation2^2 x 3^2
With multiplicity10
Distinct only5
How this was calculated
  1. Factorise: 36 = 2^2 x 3^2.
  2. With multiplicity the prime factors are 2, 2, 3, 3, summing to 10.
  3. Counting each distinct prime once gives 2, 3, summing to 5.
  4. Selected mode: with multiplicity, so sopf = 10.

Factorise a number and a simple question follows: what do its prime factors add up to? The function that answers it is called sopf(n) - the sum of prime factors. It comes in two standard flavours. With multiplicity, repeated factors are counted every time they appear: 36 = 2 x 2 x 3 x 3, so sopf(36) = 2 + 2 + 3 + 3 = 10. Counting distinct primes once, sopf(36) = 2 + 3 = 5. This calculator does both and shows the factorisation it used.

The with-multiplicity version has a beautiful property: it is completely additive, meaning sopf(a x b) = sopf(a) + sopf(b) for every a and b, with no coprimality condition. It behaves like a logarithm in disguise - turning multiplication into addition - except that it is built purely from primes. The distinct version lacks that property but answers the more elementary question of which primes are involved, and how large they run.

Enter any n up to 1,000,000 and choose the counting mode. For a prime p the two modes agree: sopf(p) = p. For prime powers they diverge cleanly - sopf(64) is 12 with multiplicity (six 2s) and 2 without - which makes powers of 2 the quickest sanity check for which mode you are in.

One more calibration point: sopf is sometimes used as a quick primality hint in recreational settings, since sopf(p) = p for primes. But sopf(n) = n also holds for n = 4 (2 + 2 = 4) - a favourite trap for the shortcut. The calculator's factorisation line settles such questions instantly, which is the honest way to use the hint.

Worked examples

sopf of 36 with multiplicity

(With multiplicity · 36)

Sum of prime factors sopf(n)10
Factorisation2^2 x 3^2
With multiplicity10
Distinct only5

sopf of 36, distinct primes only

(Distinct primes only · 36)

Sum of prime factors sopf(n)5
Factorisation2^2 x 3^2
With multiplicity10
Distinct only5

sopf of 360 with multiplicity

(With multiplicity · 360)

Sum of prime factors sopf(n)17
Factorisation2^3 x 3^2 x 5
With multiplicity17
Distinct only10

The two conventions

The with-multiplicity function is OEIS A001414; the distinct-prime function is A008472. Both are standard, and the literature's bare 'sopf' usually means the with-multiplicity version - but not always, which is why this calculator labels its modes explicitly and reports both values in the secondary outputs whichever mode you pick.

A third relative is sometimes met: the sum of prime factors counted with multiplicity but stopping at squarefree kernels... the two on this page are the ones with names, sequences and theorems attached. If a source gives sopf values that disagree with yours, a mode mismatch is the first thing to check.

Worked factorisations

36 = 2^2 x 3^2: with multiplicity 2 + 2 + 3 + 3 = 10; distinct 2 + 3 = 5. 360 = 2^3 x 3^2 x 5: with multiplicity 2 + 2 + 2 + 3 + 3 + 5 = 17; distinct 2 + 3 + 5 = 10. 12 = 2^2 x 3: 7 with multiplicity, 5 distinct. The gap between the modes grows with the exponents in the factorisation - highly composite, prime-power-rich numbers show the biggest splits.

The calculator prints the factorisation in exponent form alongside both sums, so the arithmetic can be checked at a glance. For n = 1 there are no prime factors and the sum is the empty sum, 0, under both conventions.

Complete additivity

sopf(a x b) = sopf(a) + sopf(b) holds because the prime factorisation of a product is just the merged factorisations of the factors - the multiset of primes adds, so their sum adds. This makes sopf a homomorphism from multiplication to addition, the same structural role the logarithm plays for positive reals.

Completely additive functions are determined by their values on primes, and sopf is the extremal example: it is the unique completely additive function with sopf(p) = p. Its distinct-prime cousin is merely additive over coprime arguments (it is determined by sopf(p^a) = p instead), a subtlety that shows up the moment you multiply non-coprime numbers.

How sopf behaves on average

Individual values jump around - sopf(prime) is huge, sopf(2^k) is small - but the average order is smooth: the mean of sopf(n) up to N grows like (pi^2 / 12) x N / log N... in the distinct case the constant differs, but in both cases the average is driven by the many numbers whose largest prime factor is big. Precise results of this kind belong to analytic number theory's standard toolkit.

Extremes are easy to characterise: sopf(n) is maximised at primes (sopf = n) and, for composite n, the largest values come from n = 2p with p prime. The minimum for n in a range is achieved at powers of 2. This page's range cap of a million keeps factorisation instant by trial division.

Relations to other functions

sopf sits in a family of factor-sum functions: the sum of all divisors sigma(n), the sum of unitary divisors (covered by its own page here), the total prime factor count with multiplicity (big Omega) and without (little omega). Where big Omega counts the factors, sopf weighs them; the two together nearly determine the 'shape' of a small factorisation.

There are also pretty identities: sopf of a perfect number relates to its abundancy, and the iteration 'replace n by sopf(n)' reaches a prime in a few steps from any start - a dynamical system recreational enough to have its own literature of examples, if not of theorems.

Using the calculator well

Pick the mode to match your source before comparing values; use the factorisation line to audit the result; and for prime inputs expect both modes to return the input itself. If you are generating data, the with-multiplicity mode is the one with the additive property, which makes it the right choice for checking identities of the form sopf(ab) = sopf(a) + sopf(b).

Everything here is exact integer arithmetic - no rounding, no approximation - so any disagreement with a reference is a real disagreement worth chasing, usually down to a mode mismatch or a factorisation slip.

The sopf of prime powers and products

Prime powers give the cleanest formulas: sopf(p^a) is a x p with multiplicity and p without. Semiprimes p x q give p + q under both conventions - which is why sopf appears in discussions of semiprime factorisation puzzles, where knowing the sum and product of the two primes nearly determines them.

For RSA-flavoured recreational problems this is the moral: sopf of a semiprime leaks the sum of the factors. For real cryptographic sizes the leak is useless (the sum is one equation in two enormous unknowns with no factorisation shortcut), but for puzzle-sized numbers it is often the intended key.

Iterating sopf

Apply sopf repeatedly: 100 -> 2+2+5+5 = 14 -> 2+7 = 9 -> 3+3 = 6 -> 2+3 = 5, a prime, where iteration stops (sopf(p) = p). Every starting number reaches a prime this way, because sopf(n) < n for all composite n > 4, and the descent is fast - a handful of steps even for large inputs.

The fixed points and near-fixed points of this iteration (4 maps to itself) are a small recreational topic of their own. The calculator supports the play: feed the output back in as the next input and watch the factorisations shrink.

sopf, Omega and the anatomy of a number

Three functions dissect the same factorisation at different resolutions: Omega counts prime factors with multiplicity (36 = 2^2 x 3^2 has Omega = 4), the distinct count omega ignores multiplicity (36 has omega = 2), and sopf weighs the factors themselves (36 gives 2 + 2 + 3 + 3 = 10). Together they describe a number's multiplicative anatomy the way a histogram describes data - coarsely, comparably, and surprisingly informatively.

The comparison between sopf and the number itself has its own lore: n with sopf(n) = n only for primes and 4; the ratio sopf(n)/n is largest for small, prime-rich numbers and shrinks as large prime factors dominate. Ruth-Aaron pairs push the comparison sideways - two consecutive numbers with equal sopf - and their scarcity (a handful below a thousand) shows how constraining an equality between neighbouring anatomies is.

FAQs

What is sopf(36)?

10 with multiplicity (2 + 2 + 3 + 3), or 5 counting distinct primes only (2 + 3).

What does sopf stand for?

Sum of prime factors.

Is sopf additive?

The with-multiplicity version is completely additive: sopf(a x b) = sopf(a) + sopf(b) for all a and b.

What is sopf of a prime?

The prime itself - it has exactly one prime factor under either convention.

What is sopf(1)?

0 - 1 has no prime factors, so the sum is empty.

Where is sopf catalogued?

The OEIS: A001414 with multiplicity, A008472 for distinct primes.

Sources

Related calculators

Prime Factorization Calculator
Break any whole number up to a trillion into its prime factors — with divisor count, divisor sum and largest prime factor.
Prime Omega Function Calculator
The prime omega functions: Omega(n) counts prime factors with multiplicity, omega(n) counts distinct ones, from the factorization.
Euler's Totient Calculator
Euler's totient φ(n) — how many integers up to n are coprime to n — from the distinct prime factors of n.