def generate_sequence(s, d, n):
sequence = []
for i in range(n):
sequence.append(s)
s += d
return sequence
# Read the input from the user
input_str = input("Enter the starting number, common difference, and the number of integers to generate: ")
s, d, n = map(int, input_str.split())
# Generate the sequence
sequence = generate_sequence(s, d, n)
# Print the sequence
for num in sequence:
print(num, end=" ")
generate_sequence
function takes the starting number (s
), common difference (d
), and the number of integers to generate (n
) as parameters. It creates an empty list called sequence
and then uses a loop to generate the numbers. Each number is appended to the sequence
list, and the starting number (s
) is updated by adding the common difference (d
) to it. Finally, the sequence
list is returned.