id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > factorialLoop
prev  |  next  |  chance

Write a function that computes the factorial of n (often denoted n!), i.e. the product n(n-1)(n-2)...(3)(2)(1). Your function should use a for loop and an accumulator. You may assume the factorial of zero is one. For example, when n = 6, your code should compute 1*2*3*4*5*6. When n = 7, your code should compute 1*2*3*4*5*6*7, which is (1*2*3*4*5*6)*7.


factorialLoop(4) → 24
factorialLoop(5) → 120
factorialLoop(6) → 720

...Save, Compile, Run (ctrl-enter)

def factorialLoop(n):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy