package euler

  1. Overview
  2. Docs
An arithmetic library for OCaml's standard integers

Install

Dune Dependency

Authors

Maintainers

Sources

euler-0.1.tbz
sha256=46786c629673fc8f36c6ee57764778188983f6de8e24d3003a8de21e4752919c
sha512=5273d89967cba8397139a179c243ecb7a80c008961a06bc5396316cc32651fc902a9eb0152b98f5075db4331349d6c8dc23f249ca3fc67be5b984daac9debd6c

doc/euler/Euler/index.html

Module EulerSource

This is a library for arithmetic algorithms, primarily developed to solve Project Euler problems, although it is of more general use.

Toplevel values

Commonly useful functions not related to arithmetic.

Sourceval pow : mult:('a -> 'a -> 'a) -> unit:'a -> 'a -> int -> 'a

Generic fast exponentiation. pow ~mult ~unit x n is unit composed n times to the right with x, provided that n is non‐negative. For example:

    pow ~mult:(^) ~unit:"x" "y" 5

yields "xyyyyy". Complexity: 𝒪(log(n)) calls to mult.

  • parameter mult

    the composition operator; should be associative.

  • parameter unit

    the left‐most operand of the product (most often, we use a neutral element for mult).

Sourceval memoized_fix : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b

Memoizing fixpoint combinator. Example use:

    let fib = memoized_fix@@fun fib n ->
      if n < 2 then
        1
      else
        fib (n-1) + fib (n-2)

Modules on OCaml integers

Sourcemodule Arith : sig ... end

Arithmetic on overflowing integers.

Sourcemodule Modular : sig ... end

Modular arithmetic.

Sourcemodule Diophantine : sig ... end

Solving diophantine equations, i.e. equations on integers.

Sourcemodule Primes : sig ... end

Prime numbers and integer factorization.

Sourcemodule Farey : module type of Farey
OCaml

Innovation. Community. Security.