recursively definition code example
Example 1: recursion
# modified code tranclated to python from (Drab Duck)
def fact(num):
if num <= 1:
return 1
else:
return num*fact(num-1)
Example 2: recursion
int function(int value) {
if(value < 1)
return;
function(value - 1);
printf("%d ",value);
}
Example 3: recursion
static void recursion(){ recursion(0); }
static void recursion(int x){
System.out.println("eheh " + x);
if(x != 666) recursion(x+1);
}
Example 4: recursion
Click the Did you mean
Example 5: recursion
function loop(x) {
if (x >= 10)
return;
loop(x + 1);
}
loop(0);
Example 6: Recursion
private static String subsequencesAfter(String partialSubsequence, String word) {
if (word.isEmpty()) {
return partialSubsequence;
} else {
return subsequencesAfter(partialSubsequence, word.substring(1))
+ ","
+ subsequencesAfter(partialSubsequence + word.charAt(0), word.substring(1));
}
}