Compute factorial
Java
Easy
4 views
Problem Description
Task: return factorial of n (n>=0) using loop.
Output Format
Return value
Constraints
Return 1 for n=0.
Official Solution
static long fact(int n){long r=1;for(int i=2;i<=n;i++) r*=i;return r;}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!