HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Pigeonhole, Recursion and Graph Theory
  2. /Mathematics
  3. /Recurrences and Counting by Recursion
Chapter 30 · Part 2 of 3Pigeonhole, Recursion and Graph Theory
← Previous part: The Pigeonhole PrincipleNext part: Graph Theory →
High School (11–12)Pigeonhole Principle, Recursion and Graph TheoryFree course

Recurrences and Counting by Recursion

How many ways can you climb a staircase one or two steps at a time?

  • Count the ways for a short staircase, and the longer ones follow from them.
  • That is counting by recursion.
  • You set up recurrences for puzzles, tilings and strings, and solve linear recurrences with the characteristic equation.
  • Then you meet the derangement numbers and the Catalan numbers.
  • It covers the recursion unit of the Indian olympiad syllabus, the recurrence relations of the ISI admission test and the same topics of the international olympiads.

3 lessons, about 1 h 20 min3 simulations10 problems3 practice questionsPython in every lesson

StemPy LabCreated by StemPy Lab

Free

Every lesson is open to read. Enroll to keep your place in the course. No payment needed.

This course includes

  • 3 lessons, about 1 h 20 min
  • 3 simulations with sliders
  • 3 practice questions with new numbers each time
  • 3 Python programs to run
  • 10 problems with worked solutions
  • 2 Python labs
1 question set
  • 1 revision note
  • 1 test
  • Log in to save

    Course outline (3 lessons)

    1. 1
      Lesson 1about 30 min

      Setting up a recurrence

      A recurrence gives each term of a sequence from the terms before it, together with starting values. To set one up, name the count ana_nan​, look at the first or the last step, and split into cases that are smaller copies of the same problem. The Tower of Hanoi, regions cut by lines, staircases, tilings and strings all lead to recurrences, often the Fibonacci one.

      1 simulation1 practice question1 Python program4 problems1 Python lab
      Read the lesson
    2. 2
      Lesson 2about 25 min

      Solving linear recurrences

      A linear recurrence an=pan−1+qan−2a_n = pa_{n-1} + qa_{n-2}an​=pan−1​+qan−2​ is solved by trying an=xna_n = x^nan​=xn. This gives the characteristic equation x2=px+qx^2 = px + qx2=px+q. With two different roots rrr and sss, an=Arn+Bsna_n = Ar^n + Bs^nan​=Arn+Bsn; with one repeated root rrr, an=(A+Bn)rna_n = (A + Bn)r^nan​=(A+Bn)rn. The starting values fix AAA and BBB. A constant term is removed by moving to the fixed point first.

      1 simulation1 practice question1 Python program4 problems
      Read the lesson
    3. 3
      Lesson 3about 25 min

      Derangements and Catalan numbers

      A derangement is an order in which nothing stays in its own place. By inclusion and exclusion there are Dn=n!(1−11!+12!−⋯+(−1)nn!)D_n = n!\left(1 - \frac{1}{1!} + \frac{1}{2!} - \dots + \frac{(-1)^n}{n!}\right)Dn​=n!(1−1!1​+2!1​−⋯+n!(−1)n​) of them, and Dn=(n−1)(Dn−1+Dn−2)D_n = (n - 1)(D_{n-1} + D_{n-2})Dn​=(n−1)(Dn−1​+Dn−2​). About 1e\frac{1}{e}e1​ of all orders are derangements. The Catalan numbers Cn=1n+1(2nn)C_n = \frac{1}{n + 1}\binom{2n}{n}Cn​=n+11​(n2n​) count balanced brackets, paths that stay below a diagonal and triangulations.

      1 simulation1 practice question1 Python program2 problems1 Python lab1 question set1 note
      Read the lesson

    Test Your Learning

    Recurrences and Recursion: Olympiad Style Test
    Olympiad format15 questions · 45 min
    Not started

    Your teacher

    StemPy LabStemPy Lab

    1 follower

    Loading…

    ← All Courses
    ← The Pigeonhole PrincipleGraph Theory →
    More onPigeonhole Principle, Recursion and Graph Theory

    Discussion (0)

    Log in to join the discussion.

    Loading…