pyobum
0
Q:

recursion

# modified code tranclated to python from (Drab Duck)

def fact(num):
  if num <= 1:
      return 1
  else:
    return num*fact(num-1)   
2
/*Java*/
static void recursion(){ recursion(0); }
static void recursion(int x){
	System.out.println("eheh " + x);
    if(x != 666) recursion(x+1);
}
1
/**
 * Return all subsequences of word (as defined above) separated by commas,
 * with partialSubsequence prepended to each one.
 */
private static String subsequencesAfter(String partialSubsequence, String word) {
    if (word.isEmpty()) {
        // base case
        return partialSubsequence;
    } else {
        // recursive step
        return subsequencesAfter(partialSubsequence, word.substring(1))
             + ","
             + subsequencesAfter(partialSubsequence + word.charAt(0), word.substring(1));
    }
}
0
def foo():
	foo()
0
int fact(int n)
{
    if (n < = 1) // base case
        return 1;
    else    
        return n*fact(n-1);    
}
0

New to Communities?

Join the community