Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

Factorial Recursive in Java

    private static int factorial(int i) {
        // base case
        if (i == 0 || i == 1) {
            return 1;
        } else { // general case
            return i * factorial(i - 1);
        }
    }
 

No comments:

Post a Comment

Search 24 Bytes

Loading...