You must then use a loop (for or while) to find the sum of all the numbers in the geometric sequence of 3 less than N.
The geometric sequence of 3 looks like this
1, 3, 9, 27, 81, 243, ... where you start with the number one and multiply the previous number by 3 to get the next number.
add the sequences together to get answer

What have you done already?

Try to get the sequence of numbers into a list using a for loop.
Then you can sum up the elements of the list with sum()

BTW, if the sequence is very large use a generator expression. Hint ...

# using a generator expression to sum directly
t2000 = sum(3**k for k in range(2000))
print("sum of first 2000 numbers = {}".format(t2000))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.