Leonardo number

The Leonardo numbers are a sequence of numbers given by the recurrence: Edsger W. Dijkstra[1] used them as an integral part of his smoothsort algorithm,[2] and also analyzed them in some detail.

[3] [4] A Leonardo prime is a Leonardo number that's also prime.

The first few Leonardo numbers are The first few Leonardo primes are The Leonardo numbers form a cycle in any modulo n≥2.

An easy way to see it is: The cycles for n≤8 are: The cycle always end on the pair (1,n-1), as it's the only pair which can precede the pair (1,1).

The Leonardo numbers are related to the Fibonacci numbers by the relation

From this relation it is straightforward to derive a closed-form expression for the Leonardo numbers, analogous to Binet's formula for the Fibonacci numbers: where the golden ratio

φ =

are the roots of the quadratic polynomial