''' Purpose: compute n factorial for a user supplied n ''' # n factorial is the product of numbers from 1 to n reply = input( 'Enter a number: ' ) n = int( reply ) # want to accumulate the product # initialize accumulator before the loop product = 1 # want to accumulate factors 1 through n # i takes on a new value every time we iterate through the for loop. # i takes on every value in the range ( including the first value, # not including the end value) for i in range( 1, n + 1 ): product = product * i print( i, product ) print() ; input( 'Enter when ready: ' ) ; print print( product )