Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up

Find the Missing Term in a Geometric Progression

Basic Acceptance 88.72% Points 10

You are given a geometric progression (GP) in which exactly one term is missing and represented by a placeholder (_). Your task is to find and return the missing term.

A geometric progression is a sequence in which the ratio between consecutive terms remains constant. The given sequence is guaranteed to form a valid GP when the missing term is restored.

Examples
Example 1

Input: seq = [2, 4, _, 16]

Output: 8

Explanation: The common ratio is 2. Therefore, the missing term is 8.

Example 2

Input: seq = [3, _, 27, 81]

Output: 9

Explanation: The common ratio is 3. Therefore, the missing term is 9.

Example 3

Input: seq = [_, 10, 100, 1000]

Output: 1

Explanation: The common ratio is 10. Therefore, the first term is 1.

Constraints
  • 3 <= number of known terms <= 105
  • The sequence is a valid GP apart from the one missing term.
Topics
Introduction Data Structures Basics Array
Companies
Apple ServiceNow
Added 05 Nov 2026 88.72% acceptance
Ln 1, Col 1Sign in to save your code
2 4 _ 16 32
8