Leonardo number
Set of numbers used in the smoothsort algorithm
From Wikipedia, the free encyclopedia
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 is also prime.
Name
The term "Leonardo number" was coined by Dijkstra[5][nb 1], and the derivation is not given explicitly. Given the close relationship to the famous sequence credited to Leonardo Fibonacci, he may have considered the subject trivial. There is no known nor likely connection to Leonardo da Vinci, the most common subject of that mononym.
Values
Modulo cycles
The Leonardo numbers form a cycle in any modulo . An easy way to see it is:
- If a pair of numbers modulo appears twice in the sequence, then there is a cycle.
- If we assume the main statement is false, using the previous statement, then it would imply there are an infinite number of distinct pairs of numbers between and , which is false since there are such pairs.
The cycles for are:
| Modulo | Cycle | Length |
| 2 | 1 | 1 |
| 3 | 1,1,0,2,0,0,1,2 | 8 |
| 4 | 1,1,3 | 3 |
| 5 | 1,1,3,0,4,0,0,1,2,4,2,2,0,3,4,3,3,2,1,4 | 20 |
| 6 | 1,1,3,5,3,3,1,5 | 8 |
| 7 | 1,1,3,5,2,1,4,6,4,4,2,0,3,4,1,6 | 16 |
| 8 | 1,1,3,5,1,7 | 6 |
The cycle always end on the pair , as it is the only pair which can precede the pair .
Expressions
- The following equation applies:
Relation to Fibonacci numbers
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 and are the roots of the quadratic polynomial .
Leonardo polynomials
The Leonardo polynomials is defined by [6]
- with
Equivalently, in homogeneous form, the Leonardo polynomials can be writtenas
where and
Examples of Leonardo polynomials
Substituting in the above polynomials gives the Leonardo numbers and setting gives the -Leonardo numbers.[7]