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

 

factorial


Define the function factorial, that when passed an integer (say, n), returns the product of all positive integers from 1 to n (including n). Return 1 if n < 1.


factorial(4) → 24
factorial(0) → 1
factorial(10) → 3628800

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

int factorial(int 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

Java Help

Misc Code Practice

Difficulty: 2 Post-solution available

Copyright Nick Parlante 2017 - privacy