• 07 Dec 2014 » Race to One
  • Here are two small probability puzzles. I believe the first one to be a ‘classical’ problem where a couple very different methods can be used. The second puzzle appears to be a natural extension of the first one, I don’t think I have ever seen any reference to it anywhere.

  • 02 Nov 2014 » Fast Fourier Transform for Convolution/Multiplication
  • After hearing about it quite a few times, I finally took a couple hours to understand how to use the Fast Fourier Transform (FFT) to compute a convolution or the product of two arbitrary precision integers.

  • 27 Sep 2014 » Fixed Points Of Random Permutations
  • A permutation \(\sigma\) of \([1, n]\) is a bijective function from \([1, n]\) to \([1, n]\). There are \(n!\) different permutations of \([1, n]\), a random permutation is a random variable that can take as value any permutation with probability \(1/n!\).

  • 14 Sep 2014 » Counting Coprime Pairs
  • A classical problem consists in counting the number of pairs of coprime integer below some limit \(n\). Let \(c(n)\) be this number of pairs:

  • 02 Sep 2013 » Modular Exponentiation On Integers
  • Modular exponentiation consists in computing \(x^n(\textrm{mod}~ m)\) given \(x\), \(n\), and \(m\). The classical way to efficiently implement this is to use exponentiation by squaring.

  • 18 Aug 2013 » Solving Variations Of Pythagorean Equations
  • In the previous post, we detailed a Pythagorean triple generator. The technique we used to prove it can be generalized to obtain generators solving other Diophantine equations. Let us illustrate this by giving a unique characterization of primitive triples (a, b, c) such that \(2a^2 + b^2 = c^2\).

  • 03 Aug 2013 » Pythagorean Triples Again
  • A few posts back, we saw how to generate Pythagorean triples. We used the following parametrization: primitive triples are uniquely generated by the following equations,

  • 27 Jul 2013 » Prime Factors
  • In the previous post, we used Erathostenes sieve to generate all the primes below a given limit \(N\). Using a modified version of this sieve, we could compute for any integer below \(N\) their prime decomposition. That is for any \(n < N\) we produce the unique list \((p_i, q_i)_i\) such that \((p_i)_i\) is prime, \(p_i < p_{i+1}\), and:

  • 24 Jul 2013 » Prime Sieving
  • A classical problem is to generate all the primes below a limit \(N\). For example this could be used to efficiently compute the prime decomposition of a given integer. A very simple way to do that is to use an Erathostenes Sieve.

  • 20 Jul 2013 » Using The Stern Brocot Tree
  • The method we used in the previous post to generate Pythagorean triples could be significantly improved. One of the main issues is that we are computing the GCD for all pairs \((m, n)\) and discarding pairs that are not coprime.

  • 14 Jul 2013 » Generating All Pythagorean Triples
  • As per ProjectEuler 75, we would like to generate all integer triples (a, b, c) such that \(a^2 + b^2 = c^2\) with \(a + b + c \leq N\)

ProjectEuler