# Number theory functions

Primes and divisors, greatest common divisors and modular arithmetic, Euler's totient, continued fractions, Fibonacci, Bernoulli and Catalan numbers, and integer partitions.

53 functions

## Described functions

- [is_prime](https://hilberon.com/library/is_prime)

  Test whether a whole number is prime.
- [divisors](https://hilberon.com/library/divisors)

  The positive divisors of a whole number, in increasing order.
- [euler_phi](https://hilberon.com/library/euler_phi)

  Euler's totient: how many whole numbers up to n are coprime to n.
- [fibonacci](https://hilberon.com/library/fibonacci)

  The n-th Fibonacci number, with F(1) = F(2) = 1.
- [modular_inverse](https://hilberon.com/library/modular_inverse)

  The inverse of a whole number modulo another.
- [next_prime](https://hilberon.com/library/next_prime)

  The least prime greater than a number.
- [nth_prime](https://hilberon.com/library/nth_prime)

  The n-th prime, counting 2 as the first.
- [power_mod](https://hilberon.com/library/power_mod)

  A power modulo a number: base^exponent mod modulus.
- [prime_pi](https://hilberon.com/library/prime_pi)

  How many primes are at most a number.
- [bell_b](https://hilberon.com/library/bell_b)

  The n-th Bell number: how many ways to split n items into groups.
- [bernoulli_b](https://hilberon.com/library/bernoulli_b)

  The n-th Bernoulli number.
- [carmichael_lambda](https://hilberon.com/library/carmichael_lambda)

  Carmichael function: the least power that takes every number coprime to n to 1 modulo n.
- [catalan_number](https://hilberon.com/library/catalan_number)

  The n-th Catalan number.
- [chinese_remainder](https://hilberon.com/library/chinese_remainder)

  The number that leaves given remainders on division by given moduli.
- [continued_fraction](https://hilberon.com/library/continued_fraction)

  The continued fraction of a rational number, as a list.
- [convergents](https://hilberon.com/library/convergents)

  The convergents of a continued fraction.
- [discrete_log](https://hilberon.com/library/discrete_log)

  The exponent that takes a base to a value modulo a number.
- [divisor_count](https://hilberon.com/library/divisor_count)

  How many positive divisors a whole number has.
- [divisor_sigma](https://hilberon.com/library/divisor_sigma)

  Sum of the powers of the divisors of a whole number.
- [divisor_sum](https://hilberon.com/library/divisor_sum)

  Sum of the positive divisors of a whole number.
- [euler_e](https://hilberon.com/library/euler_e)

  The n-th Euler number.
- [extended_gcd](https://hilberon.com/library/extended_gcd)

  Greatest common divisor of two whole numbers with the multipliers that give it.
- [factor_integer](https://hilberon.com/library/factor_integer)

  Prime factorization of a whole number, as a list of prime and exponent pairs.
- [from_continued_fraction](https://hilberon.com/library/from_continued_fraction)

  The number a continued fraction stands for.
- [harmonic_number](https://hilberon.com/library/harmonic_number)

  The n-th harmonic number: 1 + 1/2 + ... + 1/n.
- [integer_exponent](https://hilberon.com/library/integer_exponent)

  The exponent of a prime in a whole number.
- [integer_partitions](https://hilberon.com/library/integer_partitions)

  All the ways to write a whole number as a sum of positive whole numbers.
- [is_coprime](https://hilberon.com/library/is_coprime)

  Test whether two whole numbers have no common divisor above 1.
- [is_prime_power](https://hilberon.com/library/is_prime_power)

  Test whether a whole number is a power of a prime.
- [is_square_free](https://hilberon.com/library/is_square_free)

  Test whether no square greater than 1 divides a whole number.
- [jacobi_symbol](https://hilberon.com/library/jacobi_symbol)

  Jacobi symbol (a/n), for an odd positive n.
- [lucas_l](https://hilberon.com/library/lucas_l)

  The n-th Lucas number.
- [moebius_mu](https://hilberon.com/library/moebius_mu)

  Moebius function: 0 if a square divides n, else 1 or -1 by the parity of its prime factors.
- [multinomial](https://hilberon.com/library/multinomial)

  Multinomial coefficient: the ways to split n items into groups of the given sizes.
- [multiplicative_order](https://hilberon.com/library/multiplicative_order)

  The least power of a number that is 1 modulo another.
- [partitions_p](https://hilberon.com/library/partitions_p)

  How many ways a whole number is a sum of positive whole numbers, in any order of terms.
- [partitions_q](https://hilberon.com/library/partitions_q)

  How many ways a whole number is a sum of distinct positive whole numbers.
- [previous_prime](https://hilberon.com/library/previous_prime)

  The greatest prime less than a number.
- [prime_nu](https://hilberon.com/library/prime_nu)

  How many distinct primes divide a whole number.
- [prime_omega](https://hilberon.com/library/prime_omega)

  How many primes divide a whole number, counted with multiplicity.
- [primitive_root](https://hilberon.com/library/primitive_root)

  A primitive root of a prime: a number whose powers cover all the nonzero residues.
- [solve_congruence](https://hilberon.com/library/solve_congruence)

  Solve a congruence for a variable.
- [squares_r](https://hilberon.com/library/squares_r)

  How many ways a whole number is a sum of a given count of squares, counting order and signs.
- [stirling_s1](https://hilberon.com/library/stirling_s1)

  Stirling number of the first kind, with sign.
- [stirling_s2](https://hilberon.com/library/stirling_s2)

  Stirling number of the second kind: the ways to split n items into k groups.
- [subfactorial](https://hilberon.com/library/subfactorial)

  Subfactorial: how many ways to reorder n items so none stays in place.
- [totient](https://hilberon.com/library/totient)

  Euler's totient: how many whole numbers up to n are coprime to n.

## More functions in this category

Nobody has described these yet: each is listed with its first form.

- [ehrhart_count](https://hilberon.com/library/ehrhart_count)
- [ehrhart_data](https://hilberon.com/library/ehrhart_data)
- [integer_length](https://hilberon.com/library/integer_length)
- [is_ehrhart_certificate](https://hilberon.com/library/is_ehrhart_certificate)
- [lattice_reduce](https://hilberon.com/library/lattice_reduce)
- [powers_representations](https://hilberon.com/library/powers_representations)

## Other categories

- [Abstract algebra](https://hilberon.com/library/category/abstract-algebra) 55
- [Algebra](https://hilberon.com/library/category/algebra) 52
- [Assumptions](https://hilberon.com/library/category/assumptions) 10
- [Calculus](https://hilberon.com/library/category/calculus) 21
- [Differential and difference equations](https://hilberon.com/library/category/differential-and-difference-equations) 187
- [Elementary functions](https://hilberon.com/library/category/elementary-functions) 34
- [Equation solving](https://hilberon.com/library/category/equation-solving) 15
- [Linear algebra](https://hilberon.com/library/category/linear-algebra) 44
- [Lists](https://hilberon.com/library/category/lists) 52
- [Logic and comparison](https://hilberon.com/library/category/logic-and-comparison) 45
- [Numerical computation](https://hilberon.com/library/category/numerical-computation) 5
- [Optimization](https://hilberon.com/library/category/optimization) 6
- [Presentation](https://hilberon.com/library/category/presentation) 7
- [Probability and stochastic processes](https://hilberon.com/library/category/probability-and-stochastic-processes) 73
- [Programming](https://hilberon.com/library/category/programming) 43
- [Series and sums](https://hilberon.com/library/category/series-and-sums) 17
- [Special functions](https://hilberon.com/library/category/special-functions) 95
- [Strings](https://hilberon.com/library/category/strings) 4
- [Transforms](https://hilberon.com/library/category/transforms) 15
- [Trigonometry](https://hilberon.com/library/category/trigonometry) 28

---
Source: https://hilberon.com/library/category/number-theory
