about | help | code help+videos | done | prefs |
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) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy