To represent the geometric sequence 6, 18, 54, we can define a function that computes the \(n\)th term of the sequence. A geometric sequence can be represented by the formula:
\[ a_n = a_1 \cdot r^{(n-1)} \]
Where:
- \(a_n\) is the \(n\)th term of the sequence
- \(a_1\) is the first term of the sequence
- \(r\) is the common ratio
- \(n\) is the term number
In your sequence:
- The first term \(a_1 = 6\)
- The common ratio \(r\) can be calculated by dividing any term by the previous term. For instance, \(r = 18 / 6 = 3\).
So, the \(n\)th term of the sequence is given by:
\[ a_n = 6 \cdot 3^{(n-1)} \]
Now, here's a function in Python to represent this geometric sequence:
def geometric_sequence(n):
a1 = 6 # first term
r = 3 # common ratio
an = a1 * (r ** (n - 1)) # n-th term formula
return an
# Example usage:
for i in range(1, 4):
print(geometric_sequence(i)) # Output: 6, 18, 54
This function geometric_sequence(n)
calculates the \(n\)th term of the geometric sequence. In the loop provided as an example, n
varies from 1 to 3, yielding the terms 6, 18, and 54.