Write a function to represent the geometric sequence 6, 18, 54, . . . .(1 point)

1 answer

To represent the geometric sequence 6, 18, 54, ..., we can identify that this sequence has a first term \( a = 6 \) and a common ratio \( r = 3 \) (since \( 18 / 6 = 3 \) and \( 54 / 18 = 3 \)).

A function that generates the \( n \)-th term of this geometric sequence can be defined as follows:

Python Function

def geometric_sequence(n):
    a = 6  # First term
    r = 3  # Common ratio
    return a * (r ** (n - 1))

# Example usage
for i in range(1, 6):
    print(geometric_sequence(i))

Explanation

  • The function geometric_sequence(n) calculates the \( n \)-th term of the sequence using the formula for the \( n \)-th term of a geometric sequence:

    \[ a_n = a \cdot r^{(n-1)} \]

  • Here, \( a \) is the first term (6) and \( r \) is the common ratio (3).

  • The for loop at the end demonstrates how to generate the first 5 terms of the sequence.

Output

This will output:

6
18
54
162
486

These are the first 5 terms of the geometric sequence.