Sequence Examples: 47 Problems with Answers

Worked examples of Sequence to try before you open each solution, then practice problems with answers.

Worked Examples

Example 1

easy
Write the first five terms of the sequence an=nn+1 for n=1,2,3,…
Show solution

Answer

12,  23,  34,  45,  56

First step

1.
a1=12.

Full solution

  1. 2.
    a2=23.
  2. 3.
    a3=34.
  3. 4.
    a4=45.
  4. 5.
    a5=56.
Each term is found by substituting n into the formula. The terms increase and approach 1, illustrating that this sequence converges to 1 as n→∞.

Example 2

medium
Determine whether the sequence an=3n2+1n2+2 converges or diverges. If it converges, find the limit.

Example 3

easy
Show step-by-step output for: n=2; n=n∗3; n=n+1; OUTPUT n.

Example 4

medium
A recipe lists: (1) bake 30 min, (2) preheat oven, (3) mix batter. Why is order (2),(3),(1) correct rather than (1),(2),(3)?

Example 5

medium
A program reads two numbers, prints their sum, then their product. Write the sequence of 4 steps in plain pseudocode order.

Example 6

hard
A deploy script runs: build, run tests, push to prod. A junior reorders to: push, build, test. List 2 concrete failure modes.

Example 7

challenge
Given 4 statements S1..S4 where S3 depends on S1 and S4 depends on S2, how many valid total orderings exist?

Practice Problems

Try each one, then open the solution to compare your method.

Example 1

easy
Write the first four terms of bn=(−1)n⋅1n.

Example 2

medium
Determine whether an=2nn! converges or diverges.

Example 3

easy
Is 3,7,11,15,… a sequence or a series?

Example 4

easy
Find the 4th term of the sequence an=2n+1.

Example 5

easy
List the first three terms of an=n2.

Example 6

easy
What is the next term in 5,10,20,40,…?

Example 7

easy
Does the sequence an=1−1n increase or decrease as n grows?

Example 8

easy
Write the general term for 3,5,7,9,… starting at n=1.

Example 9

easy
In the sequence an=nn+1, which term equals 45?

Example 10

easy
Is 2,2,2,2,… a valid sequence? What is its limit?

Example 11

medium
A sequence is defined recursively by a1=3, an+1=an+4. Find a5.

Example 12

medium
The general term is an=2n−13n+2. What value do the terms approach as n→∞?

Example 13

medium
Find a formula for the nth term of 1,4,9,16,25,… and use it to find the 8th term.

Example 14

medium
The sequence an=(−1)n gives −1,1,−1,1,…. Does it converge?

Example 15

medium
Given an=an−1⋅12 with a1=16, find a4 and describe long-term behavior.

Example 16

medium
For the sequence an=2n+1, what is the difference an+1−an?

Example 17

challenge
A sequence satisfies a1=1 and an+1=an+2an+1. Show its terms approach 2.

Example 18

challenge
The Fibonacci sequence is 1,1,2,3,5,8,… with Fn+1=Fn+Fn−1. Show Fn+1Fn approaches 1+52.

Example 19

challenge
Prove the sequence an=3n2+1n2+2 is bounded above by 3 and find its limit.

Example 20

medium
Find the 10th term of the sequence defined by an=3⋅2n−1.

Example 21

medium
A sequence has an=n2n2+1. Is it increasing, and what is its limit?

Example 22

medium
Find the general term of 2,6,12,20,30,… (hint: products of consecutive integers).

Example 23

easy
Trace: x=7; y=x−2; z=y+1. What is z?

Example 24

easy
Trace: a=4; b=a+a; c=b+a. What is c?

Example 25

easy
Order the steps to send an email: (1) Click Send, (2) Type message, (3) Open email app, (4) Enter recipient. Give the correct order.

Example 26

easy
Trace: p=3; q=p; p=p+10. What is q?

Example 27

easy
Trace: s = ''; s=s+′g′; s=s+′o′. What is s?

Example 28

medium
Trace: x=10; y=x/2; x=x−y; OUTPUT x.

Example 29

medium
Order so that account balance prints correctly: (1) print balance, (2) deposit = 50, (3) balance = balance + deposit, (4) balance = 100. Give the order.

Example 30

medium
Trace: a=6; b=4; a=a+b; b=a−b; OUTPUT a, b.

Example 31

medium
Trace: m=12; m=m%5; m=m∗4; OUTPUT m.

Example 32

medium
Trace: L=[1,2]; L.append(3); L.append(L[0]); OUTPUT L.

Example 33

medium
Trace: a=2; b=a∗a; c=b∗a; d=c+b+a; OUTPUT d.

Example 34

medium
Trace: x=5; y=10; swap (no temp): x=x+y; y=x−y; x=x−y. Final x,y?

Example 35

medium
Trace: count=0; count=count+1; count=count∗2; count=count+1; OUTPUT count.

Example 36

medium
If you reorder `open file; read file; close file` to `read; open; close`, what happens at runtime?

Example 37

hard
Trace: a=1; b=2; c=3; a=b; b=c; c=a. Final a,b,c?

Example 38

hard
A statement using z appears at line 3; z is assigned at line 7. Will the program work as written? Why or why not?

Example 39

hard
Trace: x=2; y=x; x=x+1; z=x+y; y=z−x; OUTPUT x,y,z.

Example 40

challenge
Trace: a=1; b=a; a=a+b; b=a+b; a=a+b; OUTPUT a.

What to focus on

Core idea: A sequence assigns a term to each position 1,2,3,… by a generating rule; terms are listed, not added.

Common stuck point: The procedure for sequence is the easy part; the trap is treating a sequence as a sum. Asking "Am I listing terms by position (an) rather than adding them up?" first is what keeps a correct-looking calculation from being attached to the wrong concept.

Ask yourself: Am I listing terms by position (an) rather than adding them up?

Concept recap

An ordered list of numbers generated by a rule, where each number has a specific position (first, second, third,...).

A sequence is like the numbered lockers along a school hallway: each locker number holds exactly one item, the order is fixed, and a rule tells you what is inside locker n without opening the others. Asking what is in locker 10 is a sequence question; asking for the total value of lockers 1 to 10 is a series question.

Read the full lesson on Sequence