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

 

siochi@cnu.edu > factorial
prev  |  next  |  chance

factorial() -- given an int, num, return the factorial of num. The factorial of a number num is 1 * 2 * ... * num if num > 0. If num == 0, the factorial is 1. For example factorial(3) = 1 * 2 * 3 = 6. For this problem, you may assume num is not negative;


factorial(0) → 1
factorial(1) → 1
factorial(2) → 2

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

public int factorial(int num) { }

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: 150 Post-solution available

Copyright Nick Parlante 2017 - privacy