Skip to main content

20 docs tagged with "recursion"

View All Tags

fib

Write a recursive function called fib which accepts a number and returns the nth number in the Fibonacci sequence. Recall that the Fibonacci sequence is the sequence of whole numbers 1, 1, 2, 3, 5, 8, ... which starts with 1 and 1, and where every number thereafter is equal to the sum of the previous two numbers.

fib

Write a recursive function called fib which accepts a number and returns the nth number in the Fibonacci sequence. Recall that the Fibonacci sequence is the sequence of whole numbers 1, 1, 2, 3, 5, 8, ... which starts with 1 and 1, and where every number thereafter is equal to the sum of the previous two numbers.

flatten

Write a recursive function called flatten which accepts an array of arrays and returns a new array with all values flattened.

flatten

Write a recursive function called flatten which accepts an array of arrays and returns a new array with all values flattened.

fractional

Write a function factorial which accepts a number and returns the factorial of that number. A factorial is the product of an integer and all the integers below it; e.g., factorial four ( 4! ) is equal to 24, because 4 3 2 \* 1 equals 24. factorial zero (0!) is always 1.

fractional

Write a function factorial which accepts a number and returns the factorial of that number. A factorial is the product of an integer and all the integers below it; e.g., factorial four ( 4! ) is equal to 24, because 4 3 2 \* 1 equals 24. factorial zero (0!) is always 1.

isPalindrome

Write a recursive function called isPalindrome which returns true if the string passed to it is a palindrome (reads the same forward and backward). Otherwise it returns false.

isPalindrome

Write a recursive function called isPalindrome which returns true if the string passed to it is a palindrome (reads the same forward and backward). Otherwise it returns false.

Power

Write a function called power which accepts a base and an exponent. The function should return the power of the base to the exponent. This function should mimic the functionality of Math.pow() - do not worry about negative bases and exponents.

Power

Write a function called power which accepts a base and an exponent. The function should return the power of the base to the exponent. This function should mimic the functionality of Math.pow() - do not worry about negative bases and exponents.

productOfArray

Write a function called productOfArray which takes in an array of numbers and returns the product of them all.

productOfArray

Write a function called productOfArray which takes in an array of numbers and returns the product of them all.

recursiveRange

Write a function called recursiveRange which takes in an array of numbers and returns the product of them all.

recursiveRange

Write a function called recursiveRange which takes in an array of numbers and returns the product of them all.

reverse

Write a recursive function called reverse which accepts a string and returns a new string in reverse.

reverse

Write a recursive function called reverse which accepts a string and returns a new string in reverse.

someRecursive

Write a recursive function called someRecursive which accepts an array and a callback. The function returns true if a single value in the array returns true when passed to the callback. Otherwise it returns false.

someRecursive

Write a recursive function called someRecursive which accepts an array and a callback. The function returns true if a single value in the array returns true when passed to the callback. Otherwise it returns false.

Sum Recursion

Write a recursive function called sumRecursion which accepts an array and a callback. The function returns true if a single value in the array returns true when passed to the callback. Otherwise it returns false.

Sum Recursion

Write a recursive function called sumRecursion which accepts an array and a callback. The function returns true if a single value in the array returns true when passed to the callback. Otherwise it returns false.