Contact

PFACTOR Function (Gnumeric)

Math Beginner Gnumeric Gnumeric 1.3.92

Find a number’s smallest prime factor with Gnumeric PFACTOR, including prime inputs, fractional flooring and distinct VALUE and LIMIT errors.

Verification status: 19 reference, boundary and advanced-check formulas were recalculated with Gnumeric 1.12.57 ssconvert. Retained native records and independent integer calculations were checked. Version 1.12.62 was source-checked only. How formula examples are checked

Quick answer: =PFACTOR(2) gives 2 in the tested Gnumeric 1.12.57 build.

Availability and version history

  • Introduced: Gnumeric 1.3.92 release notes explicitly record the addition.
  • Supported in: Gnumeric 1.12.62; no retirement is established.
  • Scope: Desktop Gnumeric with its Number Theory plugin. English comma-separated formulas are shown.
  • Checked: October 14, 2026. Tables and the named advanced check were recalculated with 1.12.57 ssconvert. Current 1.12.62 source was inspected; the later release was not executed.

What PFACTOR returns

PFACTOR returns the smallest prime that divides its input integer. For 57, it returns 3 because 57=3×19 and no smaller prime divides 57. A prime input returns itself, so PFACTOR(97) is 97. Versioned function help.

Syntax and arguments

=PFACTOR(n)

n is one required numeric argument. The implementation floors it, then requires at least 2. This is stricter than the positive-domain convention of some other number-theory functions: PFACTOR(1) is an error. A fractional input 9.9 is treated as 9 and returns 3.

Current implementation.

Reproducible examples

These eight native integer results were independently checked by binary arithmetic or elementary number theory.

Formula Gnumeric 1.12.57 result
=PFACTOR(2) 2
=PFACTOR(3) 3
=PFACTOR(9) 3
=PFACTOR(12) 2
=PFACTOR(25) 5
=PFACTOR(49) 7
=PFACTOR(57) 3
=PFACTOR(97) 97

Practical worksheet

For an integer in A2, =PFACTOR(A2) gives one factor and =A2/PFACTOR(A2) gives the complementary quotient. For 91, the smallest prime factor is 7 and the quotient is 13. The native check =MOD(91,PFACTOR(91)) returned 0, confirming divisibility.

That quotient is not guaranteed to be prime. For 60, removing the smallest prime factor 2 leaves 30, which is still composite. The function provides a first factorization step rather than a complete list of prime factors.

Advanced interpretation and checks

Repeatedly dividing by the returned smallest factor can construct a factorization for small validated integers. For 12, the steps are 12→6→3→1 with factors 2, 2 and 3. Stop at 1; calling PFACTOR again would be outside its domain.

For a valid integer n at least 2, a result equal to n indicates n is prime. The source searches candidate primes through the square-root boundary. Large prime inputs can require more work than small composites that have an early factor. The ordinary tables do not benchmark worst-case factorization time.

Version-specific source differences

For the standard binary64 build, the older shared input bound is 2^52 = 4503599627370496. The pinned 1.12.62 expression raises it to 2^53 = 9007199254740992. This change is established by comparing the older bound with the current bound; it is not a native test of 1.12.62. Input acceptance and exact representability of every resulting integer are separate questions.

Boundaries and troubleshooting

Inputs that floor below 2 return #VALUE!, including zero, 1 and TRUE in the retained tests. An input beyond the version-specific magnitude bound returns #LIMIT!, not #NUM!. A missing argument produces #N/A. Preserve those distinctions when diagnosing a worksheet rather than converting every failure into zero.

F5 is an actually empty cell. Listed errors are native error results, not mathematical zeroes.

Formula Gnumeric 1.12.57 result
=PFACTOR(0) #VALUE!
=PFACTOR(-1) #VALUE!
=PFACTOR(0.9) #VALUE!
=PFACTOR(9.9) 3
=PFACTOR("abc") #VALUE!
=PFACTOR(F5) #VALUE!
=PFACTOR(TRUE()) #VALUE!
=PFACTOR() #N/A
=PFACTOR(1) #VALUE!
=PFACTOR(9007199254740994) #LIMIT!

Official evidence and checking scope

The retained workbook contained a deliberately stale SUM cache and an uncached SUM formula, both recalculated correctly. Native evidence covers the listed 1.12.57 cases. Other worksheet layouts and mathematical interpretations are separately explained checks. GUI entry, other locales and later-release output were not tested.