Misplaced Pages

Leonardo number

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
(Redirected from Leonardo prime) Set of numbers used in the smoothsort algorithm
This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources.
Find sources: "Leonardo number" – news · newspapers · books · scholar · JSTOR (July 2017) (Learn how and when to remove this message)

The Leonardo numbers are a sequence of numbers given by the recurrence:

L ( n ) = { 1 if  n = 0 1 if  n = 1 L ( n 1 ) + L ( n 2 ) + 1 if  n > 1 {\displaystyle L(n)={\begin{cases}1&{\mbox{if }}n=0\\1&{\mbox{if }}n=1\\L(n-1)+L(n-2)+1&{\mbox{if }}n>1\\\end{cases}}}

Edsger W. Dijkstra used them as an integral part of his smoothsort algorithm, and also analyzed them in some detail.

A Leonardo prime is a Leonardo number that's also prime.

Values

The first few Leonardo numbers are

1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361, ... (sequence A001595 in the OEIS)

The first few Leonardo primes are

3, 5, 41, 67, 109, 1973, 5167, 2692537, 11405773, 126491971, 331160281, 535828591, 279167724889, 145446920496281, 28944668049352441, 5760134388741632239, 63880869269980199809, 167242286979696845953, 597222253637954133837103, ... (sequence A145912 in the OEIS)

Modulo cycles

The Leonardo numbers form a cycle in any modulo n≥2. An easy way to see it is:

  • If a pair of numbers modulo n appears twice in the sequence, then there's a cycle.
  • If we assume the main statement is false, using the previous statement, then it would imply there's infinite distinct pairs of numbers between 0 and n-1, which is false since there are n such pairs.

The cycles for n≤8 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 (1,n-1), as it's the only pair which can precede the pair (1,1).

Expressions

  • The following equation applies:
L ( n ) = 2 L ( n 1 ) L ( n 3 ) {\displaystyle L(n)=2L(n-1)-L(n-3)}
Proof

L ( n ) = L ( n 1 ) + L ( n 2 ) + 1 = L ( n 1 ) + L ( n 2 ) + 1 + L ( n 3 ) L ( n 3 ) = 2 L ( n 1 ) L ( n 3 ) {\displaystyle L(n)=L(n-1)+L(n-2)+1=L(n-1)+L(n-2)+1+L(n-3)-L(n-3)=2L(n-1)-L(n-3)}

Relation to Fibonacci numbers

The Leonardo numbers are related to the Fibonacci numbers by the relation L ( n ) = 2 F ( n + 1 ) 1 , n 0 {\displaystyle L(n)=2F(n+1)-1,n\geq 0} .

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:

L ( n ) = 2 φ n + 1 ψ n + 1 φ ψ 1 = 2 5 ( φ n + 1 ψ n + 1 ) 1 = 2 F ( n + 1 ) 1 {\displaystyle L(n)=2{\frac {\varphi ^{n+1}-\psi ^{n+1}}{\varphi -\psi }}-1={\frac {2}{\sqrt {5}}}\left(\varphi ^{n+1}-\psi ^{n+1}\right)-1=2F(n+1)-1}

where the golden ratio φ = ( 1 + 5 ) / 2 {\displaystyle \varphi =\left(1+{\sqrt {5}}\right)/2} and ψ = ( 1 5 ) / 2 {\displaystyle \psi =\left(1-{\sqrt {5}}\right)/2} are the roots of the quadratic polynomial x 2 x 1 = 0 {\displaystyle x^{2}-x-1=0} .

References

  1. "E.W.Dijkstra Archive: Fibonacci numbers and Leonardo numbers. (EWD 797)". www.cs.utexas.edu. Retrieved 2020-08-11.
  2. Dijkstra, Edsger W. Smoothsort – an alternative to sorting in situ (EWD-796a) (PDF). E.W. Dijkstra Archive. Center for American History, University of Texas at Austin. (transcription)
  3. "E.W.Dijkstra Archive: Smoothsort, an alternative for sorting in situ (EWD 796a)". www.cs.utexas.edu. Retrieved 2020-08-11.
  4. "Leonardo Number - GeeksforGeeks". www.geeksforgeeks.org. 18 October 2017. Retrieved 2022-10-08.

External links

Classes of natural numbers
Powers and related numbers
Of the form a × 2 ± 1
Other polynomial numbers
Recursively defined numbers
Possessing a specific set of other numbers
Expressible via specific sums
Figurate numbers
2-dimensional
centered
non-centered
3-dimensional
centered
non-centered
pyramidal
4-dimensional
non-centered
Combinatorial numbers
Primes
Pseudoprimes
Arithmetic functions and dynamics
Divisor functions
Prime omega functions
Euler's totient function
Aliquot sequences
Primorial
Other prime factor or divisor related numbers
Numeral system-dependent numbers
Arithmetic functions
and dynamics
Digit sum
Digit product
Coding-related
Other
P-adic numbers-related
Digit-composition related
Digit-permutation related
Divisor-related
Other
Binary numbers
Generated via a sieve
Sorting related
Natural language related
Graphemics related
Categories: