Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

recursion java

    public static  int exponent(int n){
        int ans;
        if(n == 0)
            return 1;
        else if(n%2 == 0){
            int k = exponent(n/2);
            ans = k*k;
        }
        ans= 2 * exponent(n-1);

        return ans ;
    }
Source by pages.cs.wisc.edu #
 
PREVIOUS NEXT
Tagged: #recursion #java
ADD COMMENT
Topic
Name
4+3 =