Basic recursive method - factorial

Posted by bob on Stack Overflow See other posts from Stack Overflow or by bob
Published on 2010-05-10T13:05:52Z Indexed on 2010/05/10 13:14 UTC
Read the original article Hit count: 279

Filed under:
|
|

I am practising recursion and cant see why this method doesnt seem to work any ideas?

    public void fact()
    {
        fact(5);
    }

    public int fact(int n)
    {
        if(n == 1){
            return 1;
        }
        return n * (fact(n-1));
    }
}

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about factorial