fmpq_harmonic_ui, _fmpq_harmonic_ui
#include <flint/fmpq.h>Values whose numerator and denominator fit in a word (n \le 46 on a 64-bit machine) are read from a table. For larger n the function uses H_n = H_{\lfloor n/2 \rfloor}/2 + \sum_{k \le n,\, k \text{ odd}} 1/k recursively, which gives every odd k a weight (2^d - 1)/2^{d-1} that depends only on the dyadic range n/2^d < k \le n/2^{d-1}, and sums the weighted odd terms by Binary splitting and product trees, accumulating word-size partial sums in the base case. A final GCD puts the result in lowest terms. The cost is O(M(n \log n) \log n) bit operations.
The FLINT team, “fmpq_harmonic_ui, _fmpq_harmonic_ui (fmpq.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpq/fmpq_harmonic_ui.html (generated 2026-10-20).
@misc{flint-doc-fmpq-fmpq-harmonic-ui,
author = {{The FLINT team}},
title = {{fmpq\_harmonic\_ui, \_fmpq\_harmonic\_ui (fmpq.h)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/fmpq/fmpq_harmonic_ui.html},
note = {Generated 2026-10-20}
}