I have an iterative function, f(x) = ax + b, which I want to repeat N times. My steps are as follows
1.) Define the iterative function
2.) Assign a value to each repetition
3.) Stop at the Nth repetition
# Define repeating function
f += a*f + b
# Assign values to iterations
# Stop iterating at Nth value
for i in range(N+1):
f += f(i)
I'm unsure of how to label each iteration of the function. My first thought is to create a list of all values of the function.
The first thing is to declare your function, in Python there are several ways to do it. When a function is small it is usually defined as a lambda. A lambda follows the syntax.
Then we would have to define the initial values, in this case I will call the final value v and the number of iterations N
The last thing is to call the function N times, for this I use a for loop