Team 9

Sequence & Series Calculator

Build an app that generates and analyzes arithmetic progressions (AP), geometric progressions (GP), calculates nth term, partial sums, and checks convergence of geometric series.

🎯 Learning Goals

  • Master Arithmetic & Geometric Progression formulas
  • Understand Convergence conditions for infinite series
  • Implement Loop structures in MIT App Inventor
  • Work with dynamic text joining and power functions

🌎 Why This Matters

Sequences and series are used in finance (calculating interest), computer science (algorithms), and physics (wave harmonics). Understanding how they grow helps predict future trends and sum infinite processes.

📖Understanding Sequences & Series

Theory Masterclass
"

A sequence is an ordered list of numbers following a pattern. A series is the sum of the terms of a sequence. Arithmetic Progression (AP): Each term differs from the previous by a constant called the "common difference" (d). Example: 2, 5, 8, 11, 14... (d = 3) nth term: aₙ = a₁ + (n-1)d Sum of n terms: Sₙ = n/2 × (2a₁ + (n-1)d) = n/2 × (first + last) Geometric Progression (GP): Each term is multiplied by a constant called the "common ratio" (r). Example: 3, 6, 12, 24, 48... (r = 2) nth term: aₙ = a₁ × r^(n-1) Sum of n terms: Sₙ = a₁(rⁿ - 1)/(r - 1) when r ≠ 1 Convergence (Infinite GP): If |r| < 1, the infinite GP converges: S∞ = a₁ / (1 - r) If |r| ≥ 1, the series diverges (sum goes to infinity). Example: 1 + 1/2 + 1/4 + 1/8 + ... = 2 (a₁=1, r=0.5, S∞ = 1/(1-0.5) = 2)

Mathematical Foundation

fxAP nth term: aₙ = a₁ + (n-1)d
fxAP Sum: Sₙ = n/2 × (2a₁ + (n-1)d)
fxGP nth term: aₙ = a₁ × r^(n-1)
fxGP Sum: Sₙ = a₁(rⁿ-1)/(r-1)
fxInfinite GP: S∞ = a₁/(1-r), only if |r| < 1

🎨Part A — Designer View (UI Design)

Open MIT App Inventor → Switch to Designer view. Follow each step below to build the interface.

1

1. Screen Basics

• Go to the **Properties** panel (right) for **Screen1**. • Set **Title** to "Sequence Calculator". • Set **AlignHorizontal** to Center. • Set **BackgroundColor** to dark grey.

2

2. Input Fields

• Drag 3 **TextBoxes** (User Interface). • Rename them: 'FirstTermTxt', 'DiffTxt', 'TermsNumTxt'. • Give them hints: "First term (a)", "Common Diff/Ratio (d/r)", "Total terms (n)". • Set all to **NumbersOnly**.

3

3. Action Buttons

• Drag a **HorizontalArrangement**. • Drag 2 **Buttons** inside. • Rename: 'APBtn' (Text: "Arithmetic") and 'GPBtn' (Text: "Geometric"). • Style them with different colors.

4

4. Result Display

• Drag a **Label**. • Rename it to 'ResultLbl'. • Set **FontSize** to 18, **Text** to "Sequence will appear here". • Make it **MultiLine** or check 'Fill Parent' for width.

🧩Part B — Blocks View (Logic & Calculation)

Switch to Blocks view. Now add the logic that makes your app actually work.

1

1. Switch to Blocks

• Click the **Blocks** button at the top right of the Designer screen.

2

2. The AP Logic (Addition)

• Click **APBtn**. Drag out the gold 'when APBtn.Click' block. • Go to the **Variables** drawer (Orange). Use 'set CurrentVal to [FirstTermTxt.Text]'. • Go to the **Control** drawer (Dark Orange). Drag the 'for each number from 1 to n' block. • Inside the loop: [set CurrentVal to] [CurrentVal] + [DiffTxt.Text]. • Use the Blue **Math** '+' block for addition.

3

3. The GP Logic (Multiplication)

• Geometric Progression is almost identical to AP. • Instead of adding the difference, you MULTIPLY by the ratio. • Go to the **Math** drawer (Blue). Drag out the '*' block. • Logic: [set CurrentVal to] [CurrentVal] * [DiffTxt.Text].

4

4. Showing the Result

• Go to the **Text** drawer (Bright Pink). Drag a 'join' block. • Inside your loop: [set ResultLbl.Text to] [join] [ResultLbl.Text] [", "] [CurrentVal]. • This builds a comma-separated list of your sequence numbers.

🧪Testing Your App

  • AP: a₁=2, d=3, n=5 → Sequence: 2, 5, 8, 11, 14. Sum = 40
  • GP: a₁=3, r=2, n=4 → Sequence: 3, 6, 12, 24. Sum = 45
  • GP: a₁=1, r=0.5 → Converges. S∞ = 2
  • GP: a₁=1, r=2 → Diverges. No infinite sum
  • AP: a₁=10, d=-2, n=6 → 10, 8, 6, 4, 2, 0

🚀Bonus Challenges

Extra credit — impress your instructor

  • Add Harmonic Series: 1 + 1/2 + 1/3 + ... + 1/n
  • Visualize the sequence on a Canvas as a bar chart
  • Add 'Find d/r given two terms' reverse calculator
  • Support entering a sequence and identifying if it's AP or GP