Generate Fibonacci Sequence

Generate the famous Fibonacci sequence:

Fibonacci Formula:
F₀ = 0, F₁ = 1
Fₙ = Fₙ₋₁ + Fₙ₋₂ for n ≥ 2
Example: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
Golden Ratio: Fₙ₊₁/Fₙ → φ ≈ 1.618033988749895

The Fibonacci Sequence

The Fibonacci sequence is one of the most famous and important mathematical sequences in history. Each number is the sum of the two preceding ones, creating patterns that appear throughout nature, art, and mathematics.

What is the Fibonacci Sequence?

📊 Definition

Each number is the sum of the two preceding ones
F₀ = 0, F₁ = 1
Fₙ = Fₙ₋₁ + Fₙ₋₂ for n ≥ 2
Infinite sequence with remarkable properties
Grows exponentially
Ratio approaches golden ratio φ

🔢 First 20 Fibonacci Numbers

F₀: 0
F₁: 1
F₂: 1
F₃: 2
F₄: 3
F₅: 5
F₆: 8
F₇: 13
F₈: 21
F₉: 34
F₁₀: 55
F₁₁: 89
F₁₂: 144
F₁₃: 233
F₁₄: 377
F₁₅: 610
F₁₆: 987
F₁₇: 1597
F₁₈: 2584
F₁₉: 4181

🌟 Golden Ratio Connection

Fₙ₊₁/Fₙ approaches φ ≈ 1.618033988749895
Golden ratio appears in nature and art
Divine proportion in architecture
Most aesthetically pleasing ratio
Found in pentagons and pentagrams

Fibonacci Properties

➕ Addition Rule

Every number is sum of previous two
F₃ = F₂ + F₁ = 1 + 1 = 2
F₄ = F₃ + F₂ = 2 + 1 = 3
F₅ = F₄ + F₃ = 3 + 2 = 5
F₆ = F₅ + F₄ = 5 + 3 = 8
Pattern continues infinitely

⚖️ Even/Odd Pattern

Even numbers: F₃, F₆, F₉, F₁₂, ...
Odd numbers: F₁, F₂, F₄, F₅, F₇, F₈, ...
Pattern repeats every 3 numbers
F₃ₙ is always even
Related to modulo 2 arithmetic

🔄 Cassini's Identity

Fₙ₋₁ × Fₙ₊₁ - Fₙ² = (-1)ⁿ
For n=2: 1×3 - 1² = 3-1 = 2 = (-1)²
For n=3: 2×5 - 3² = 10-9 = 1 = (-1)³
Beautiful mathematical relationship

📐 Divisibility Rules

Every 3rd number divisible by 2
Every 4th number divisible by 3
Every 5th number divisible by 5
Every 6th number divisible by 8
Patterns in number theory

Practical Applications

🌿 Nature & Biology

Plant leaf arrangements (phyllotaxis)
Pineapple scales and pine cones
Sunflower seed patterns
Chambered nautilus shell
Rabbit population growth model
DNA helix structures

🎨 Art & Architecture

Golden ratio in Renaissance art
Parthenon proportions
Leonardo da Vinci's Vitruvian Man
Mona Lisa composition
Modern graphic design
Architectural harmony

💰 Finance & Economics

Fibonacci retracements in trading
Technical analysis patterns
Elliot Wave theory
Market cycle analysis
Investment timing
Risk management

💻 Computer Science

Dynamic programming examples
Recursive algorithm teaching
Memoization demonstrations
Fibonacci search algorithm
Efficient computation methods
Algorithm complexity analysis

🎵 Music & Sound

Musical scales and intervals
Fibonacci rhythms in composition
Harmonic series relationships
Sound wave patterns
Musical form structures
Acoustic design

🔬 Science & Mathematics

Continued fraction expansions
Lucas number relationships
Pell number connections
Number theory applications
Combinatorial mathematics
Graph theory

The Golden Ratio (φ)

🔢 Mathematical Definition

φ = (1 + √5)/2 ≈ 1.618033988749895
Irrational number
Positive root of x² - x - 1 = 0
Golden ratio conjugate: φ - 1 = 1/φ
Related to Fibonacci sequence
Fₙ₊₁/Fₙ → φ as n → ∞

🎨 Aesthetic Properties

Most aesthetically pleasing ratio
Appears in art and architecture
Golden rectangle proportions
Divine proportion
Visual harmony
Human preference for ratio

🌟 Natural Occurrences

Human face proportions
Animal body ratios
Plant growth patterns
Spiral galaxy structures
Crystal formations
Molecular structures

📐 Geometric Properties

Golden rectangle: 1:φ
Golden triangle: isosceles with base angles
Pentagon and pentagram
Regular dodecahedron
Platonic solids
Geometric constructions

💡 Fibonacci Tip: The ratio of consecutive Fibonacci numbers approaches the golden ratio (φ ≈ 1.618), which appears throughout nature and art. This ratio is considered aesthetically pleasing and appears in everything from flower petals to architectural masterpieces.

Advanced Fibonacci Concepts

🔄 Lucas Numbers

Lucas sequence: 2, 1, 3, 4, 7, 11, 18, 29, ...
Lₙ = Fₙ₋₁ + Fₙ₊₁
Similar properties to Fibonacci
Every third Lucas number is even
Divisibility properties

🎯 Pisano Period

Fibonacci sequence modulo m
Periodic behavior
Pisano period length
Entry point of zero
Mathematical periodicity
Number theory applications

📊 Binet's Formula

Fₙ = [φⁿ - (-φ)⁻ⁿ]/√5
Closed-form expression
Exact calculation method
Golden ratio formula
Mathematical precision
Computational efficiency

🔐 Cryptographic Applications

Fibonacci-based encryption
Pseudorandom number generation
Hash function construction
Digital signature algorithms
Secure communication
Randomness properties

Historical Development

🏛️ Ancient Origins

Sanskrit prosody in ancient India
Virahanka (6th century)
Indian mathematics
Poetic meter analysis
Ancient counting methods
Rhythmic patterns

📚 Medieval Mathematics

Leonardo Fibonacci (1202)
Liber Abaci (1202)
Rabbit population problem
European introduction
Commercial mathematics
Practical applications

⚙️ Modern Applications

Computer algorithms
Financial analysis
Scientific computing
Art and design
Nature modeling
Educational tools

Fibonacci in Nature

🌸 Plant Growth

Leaf phyllotaxis
Pine cone spirals
Sunflower seed arrangements
Pineapple scale patterns
Fern frond development
Flower petal counts

🐾 Animal Patterns

Rabbit population growth
Bird flight patterns
Animal breeding cycles
Shell spiral growth
Horn and tusk shapes
Bone structure ratios

🌊 Natural Spirals

Hurricane spiral arms
Galaxy spiral arms
Whirlpool patterns
Water vortex shapes
Smoke ring formations
Natural flow patterns

💎 Crystal Structures

Quasicrystal formations
Molecular arrangements
Crystal growth patterns
Atomic lattice structures
Material science
Physical chemistry