Untitled
unknown
python
a year ago
429 B
2
Indexable
# Read the number of terms N N = int(input().strip()) # Initialize the first term tn = 1 # Initialize an empty list to store the terms terms = [] # Loop through the sequence to generate N terms for n in range(1, N + 1): terms.append(str(tn)) tn += n + 1 # Update the term based on the previous one # Convert the list of terms to a single string separated by space and print it print(" ".join(terms))
Editor is loading...