Answers for "recursion"

27

recursion

print("Hello World")
Posted by: Guest on November-24-2019
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

Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Did you mean: recursion
Posted by: Guest on January-06-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
0

Recursion

See Recursion.
Posted by: Guest on June-18-2021
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

#https://github.com/aspittel/coding-cheat-sheets/blob/master/fundamentals/recursion.md

def factorial(n):
	if n <= 1:
		return 1
	return n * factorial(n - 1)

# Memoization
# Memoization is often useful in recursion. This is when the results of a function call are remembered so they can be used again in later function calls. This is like caching your results to use again.

# Code Example

factorial_memo = {}

def factorial(n):
	if n <= 1:
		return 1
	elif n not in factorial_memo:
		factorial_memo[n] = n * factorial(n-1)
	return factorial_memo[n]
# Tail Recursion
# Tail recursion is where calculations are performed first and then the recursive call is executed. Some programming languages, usually functional ones, optimize tail calls so they take up less room on the call stack.

def factorial(n, running_total=1):
	if n <= 1:
		return running_total
	return factorial(n-1, n * running_total)
Posted by: Guest on September-20-2021
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

Python Answers by Framework

Browse Popular Code Answers by Language