(upbeat music)
- [Instructor] Your challenge for this chapter
is to create a non-recursive function
for calculating factorials.
Earlier in this chapter we covered a recursive function
that calculates factorials.
This function is interesting and clever,
but it has a serious flaw.
Each iteration adds a function call to the stack
along with its parameters and return values,
and for large values of n.
This can quickly overflow the stack
causing crashes, errors and worse.
The solution is to create a non-recursive function
to perform the same calculation.
By way of refresher, the factorial of n is the product
of all positive integers less than or equal to n.
The purpose of this challenge is for you to create
a function that takes a value and returns a value.
It should take about 10 minutes,
but it's okay if it takes longer,
or if you need to spend time experimenting and learning.
And remember, your function should not use recursion.