recursão

Recursive sequence sum

I am implementing a recursive code that sums the following sequence: x + x^2 / 2 + x^3 / 3... x^n / n, for this sum, I though ... n - 1) def Soma_Seq (x, n): if n == 0: return 0 else: return x + Soma_Seq(potencia(x, n - 1), n - 1) / n

RuntimeError: maximum number of recursive calls exceeded-python

fibonacci_cache = {} def fibonacci(n): if n in fibonacci_cache: return fibonacci_cache[n] if n==1: v ... ersion: Python 2.7.10. Returned me this error: RuntimeError: maximum recursion depth exceeded. How do I solve this problem?

When to use recursion and when to use loops?

A problem can be solved and get the same result used a loop or through recursive calls to a function. Considering that the programming language being used has both features, How do you know when one is better than the other?

recursive function in python to calculate sum of elements of a list

I am having difficulty in an exercise whose I should show the sum of all elements of a list recursively. The code I came up ... soma Note: as I said, I don't know how to apply the recursion part, so I tried something random. Ignore else's code block.

Recursive fibonacci printing

I'm having problems with the recursive fibonacci function, in the exercise is asked to print inside the function or even usin ... The function should print the first n numbers separated by spaces, by example, for n = 10: 0 1 1 2 3 5 8 13 21 34"

Recursive palindrome C

My functions are not working properly, always the program tells me that it is not palindrome, for any situation. Follow the C ... else printf("Nao eh palindromo"); } int main() { char m[30] = {"anna"}; palindromo(m); return 0; }

Move all files with the extension.prj for a folder

I would like to know if the following situation is possible: There are several folders inside each other... and inside them ... th the extension .prj. Is it possible to read all the folders, go finding the files .prj, and go pasting in a result folder?

What is a recursive function?

I've always heard that recursion is a smart idea that plays a central role in functional programming and Computer Science in ... l recursion and tail. What is a recursive function? What are the main characteristics between mutual and tail recursion?

Python - ' int ' object is not iterable

Hello, I'm creating a character converter for your ascii code via a recursive Python function. However I am having a problem ... 897 which corresponds to the conversion of each of the characters to ASCII. Can anyone help me figure out where I'm failing?

Recursive function with strings-Python

I'm not able to solve an exercise. The statement is as follows: implement the Disturb(n) function that returns a string conta ... else: string += str(count) + ' elefantes ' + incomodam(count) + 'muito mais ' return string

Recursive binary tree and sum of leaves

Friends I'm having trouble solving this exercise, and I don't know how to do it anymore. I got to implement the tree with rec ... of a node, it will be possible to add other nodes Recursion do not use Java type complexes (HashMap s, List s and etc)

Sorting in C using recursion

I need to make a vector ordering code using recursion. I searched about sorting methods and found two that would be interesti ... e second, third, etc. Another question: What is better to use for sort a vector with recursion: selection sort or quicksort?

Recursion in Python 3

I'm having a hard time organizing a recursive summation formula in Python. Need to calculate: My Code: def seq1(n): ... onError: maximum recursion depth exceeded in comparison I would like to know how to do the calculation, grateful right now!

Determine the nth Fibonacci term with recursion

I'm not understanding anything about recursive functions, even debugging, it's too confusing for me. Can anyone explain me in ... #linha4 return fibonacci(n-1)+fibonacci(n-2) #linha5 fibonacci(5) #linha6

C Bank withdrawal algorithm using recursion

I am having doubts about a bank withdrawal algorithm in C. First of all it is better to pass the statement: ATMs in banks a ... =20; else if(x==4) n[x].v=50; else if(x==5) n[x].v=100; } printf("%d\n",forms(n,t,start(n,t,5)); return 0; }

What is the advantage of using recursive functions?

I recently discovered the famous (or not so famous) recursive functions and found the concept very interesting. However, du ... ion instead of a common repeating loop (e.g. for/while)? What would be the ideal situations for using recursive functions ?

Recursive functions in C++: examples

I'm starting learning in C++ and, for the moment, I'm focusing on recursive functions. I've seen some interesting examples, l ... road. It's just about seeing and sharing other examples that can be useful to those who are learning the language. Thank you!

Binary tree with in-order and pre-order path

I have some doubts about the path taken by this binary tree: Could you classify it as binary? Since she has knots with 3 ... ? Pre-Order: 35,80,7,11,12,15,6,0,1,2,9,3,18,8,73,13,27,71 In-Order: 12,11,0,1,2,6,9,15,7,18,8,3,80,35,13,27,71,73

java.lang.StackOverflowError: stack size 1038kb

I'm making an algorithm that converts a bitmap leaving it grayscale. I managed to do using for but would like to do it recur ... lic void run() { img.setImageBitmap(bm_3); } }); } }).start(); }

Why is a function calling itself?

def clinic(): print "Voce acabou de entrar na clinica!" print "Voce entra pela porta a esquerda (left) ou a direita ( ... n the end? Only 1 of them would apparently work the code. It wasn't me who wrote the code, it was from a course I'm doing.