I am trying to define a recursive geometric function that will ask the user the first value of the sequence and the multiplier value for the sequence. The function should give a sequence of the desired length as the argument and produce as the return value a list of the arbitrary Geometric sequence of that length. As a clarifying example, if the user provides 5 as the start value and 3 as the multiplier with the desired length of 6, the first 6 elements of the arbitrary geometric sequence would be [5, 15, 45, 135, 405, 1215]
When I run this code, I get the sequence in weirdly random order. This is my code so far:
# This will define a recursive arbitrary Geometric sequence function
def recursive_geo_helper(length):
start = int(input("Enter the first value of the sequence: "))
multiplier = int(input("Enter the value that must be multiplied: "))
return actual_recursive_geo(length, start, multiplier)
def actual_recursive_geo(length, start, multiplier):
sequence = []
# print(start)
if length <= 1:
exit()
# return sequence
else:
sequence.append(start)
start = start * multiplier
length = length - 1
return actual_recursive_geo(length, start, multiplier)
#recursive_geo_helper(5)
print(recursive_geo_helper(6))