Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

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

    Test whether a whole number is prime.

  • divisors

    The positive divisors of a whole number, in increasing order.

  • euler_phi

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

  • fibonacci

    The n-th Fibonacci number, with F(1) = F(2) = 1.

  • modular_inverse

    The inverse of a whole number modulo another.

  • next_prime

    The least prime greater than a number.

  • nth_prime

    The n-th prime, counting 2 as the first.

  • power_mod

    A power modulo a number: base^exponent mod modulus.

  • prime_pi

    How many primes are at most a number.

  • bell_b

    The n-th Bell number: how many ways to split n items into groups.

  • bernoulli_b

    The n-th Bernoulli number.

  • carmichael_lambda

    Carmichael function: the least power that takes every number coprime to n to 1 modulo n.

  • catalan_number

    The n-th Catalan number.

  • chinese_remainder

    The number that leaves given remainders on division by given moduli.

  • continued_fraction

    The continued fraction of a rational number, as a list.

  • convergents

    The convergents of a continued fraction.

  • discrete_log

    The exponent that takes a base to a value modulo a number.

  • divisor_count

    How many positive divisors a whole number has.

  • divisor_sigma

    Sum of the powers of the divisors of a whole number.

  • divisor_sum

    Sum of the positive divisors of a whole number.

  • euler_e

    The n-th Euler number.

  • extended_gcd

    Greatest common divisor of two whole numbers with the multipliers that give it.

  • factor_integer

    Prime factorization of a whole number, as a list of prime and exponent pairs.

  • from_continued_fraction

    The number a continued fraction stands for.

  • harmonic_number

    The n-th harmonic number: 1 + 1/2 + ... + 1/n.

  • integer_exponent

    The exponent of a prime in a whole number.

  • integer_partitions

    All the ways to write a whole number as a sum of positive whole numbers.

  • is_coprime

    Test whether two whole numbers have no common divisor above 1.

  • is_prime_power

    Test whether a whole number is a power of a prime.

  • is_square_free

    Test whether no square greater than 1 divides a whole number.

  • jacobi_symbol

    Jacobi symbol (a/n), for an odd positive n.

  • lucas_l

    The n-th Lucas number.

  • moebius_mu

    Moebius function: 0 if a square divides n, else 1 or -1 by the parity of its prime factors.

  • multinomial

    Multinomial coefficient: the ways to split n items into groups of the given sizes.

  • multiplicative_order

    The least power of a number that is 1 modulo another.

  • partitions_p

    How many ways a whole number is a sum of positive whole numbers, in any order of terms.

  • partitions_q

    How many ways a whole number is a sum of distinct positive whole numbers.

  • previous_prime

    The greatest prime less than a number.

  • prime_nu

    How many distinct primes divide a whole number.

  • prime_omega

    How many primes divide a whole number, counted with multiplicity.

  • primitive_root

    A primitive root of a prime: a number whose powers cover all the nonzero residues.

  • solve_congruence

    Solve a congruence for a variable.

  • squares_r

    How many ways a whole number is a sum of a given count of squares, counting order and signs.

  • stirling_s1

    Stirling number of the first kind, with sign.

  • stirling_s2

    Stirling number of the second kind: the ways to split n items into k groups.

  • subfactorial

    Subfactorial: how many ways to reorder n items so none stays in place.

  • 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.

Other categories

Last updated