CodeLab Solution 20852




CS125 CodeLab Solutions

CodeLab Solution 20852

Write a method called fact that recursively calculates the factorial value of its single int parameter . The value returned by fact is a long..

[cc lang=”JAVA”] public long fact(int n) {
if (n <= 1) { return 1; } else { return (fact(n-1) * (long) n); } } [/cc]


No Comments Yet.

Leave a comment

You must be Logged in to post a comment.