Answers for "recursively definition"

1

recursion

int function(int value) {
   if(value < 1)
      return;
   function(value - 1);

   printf("%d ",value);   
}
Posted by: Guest on April-21-2021
3

recursion

# modified code tranclated to python from (Drab Duck)

def fact(num):
  if num <= 1:
      return 1
  else:
    return num*fact(num-1)
Posted by: Guest on October-12-2020
1

recursion

/*Java*/
static void recursion(){ recursion(0); }
static void recursion(int x){
	System.out.println("eheh " + x);
    if(x != 666) recursion(x+1);
}
Posted by: Guest on October-28-2020
0

recursion

function loop(x) {
  if (x >= 10) // "x >= 10" is the exit condition (equivalent to "!(x < 10)")
    return;
  // do stuff
  loop(x + 1); // the recursive call
}
loop(0);
Posted by: Guest on December-23-2020
0

recursion

def is_divisible(x, y):
    if x % y == 0:
        return True
    else:
        return False

def is_power(a, b):
    if a == 1 or b == 1:                           # a more succinct way to test base case
        return a == 1  
    return is_divisible(a, b) and is_power(a/b, b) # divisible and recursions report True?
Posted by: Guest on July-13-2021
0

Recursion

/**
 * 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));
    }
}
Posted by: Guest on October-16-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language