рекурсия

Help with the function in Python

Hello everyone I'm trying to write a function that would: If the number is a multiple of 7, then the number is a multiple of ... ish the number originally entered from the nearest one...in another way, I can't implement =\ Thank you very much in advance!

the product of the C++Fibonacci numbers

You need to recursively calculate the product of the Fibonacci numbers from 1 to N in theory, everything is normal, but in pr ... urn 1; else return fibproduct(fib(m-1)) * (fib(m)); } int main(void) { cout << fibproduct(4); return 0; }

Calculating a list of Fibonacci numbers by recursion

Using recursion, I calculate the Fibonacci numbers. I want to return a list of Fibonacci numbers of length n, but I get an e ... .append(fib(n-1) + fib(n-2)) return s I don't understand why this is happening. Thank you in advance for your help.

Python recursion, a common variable

There is such a function: def foo(): dosomething() foo() You need to somehow store the result of all calls to dosome ... e_list) How can I do without defining a list of some_list outside of the foo() function and return the result with a return?

Generating subsets algorithm

I am studying the book "Olympiad programming"by A. Laaksonen. There is a problem about generating subsets, and the following ... , but if it is {1, 2, 3, 1}? Then it won't work anymore. Question how to finalize it, so that it finds all subsets correctly?

How does the java factorial calculation program work?

I analyze a program that counts the factorial and do not understand how it works. I understand this so that result = (5-1)*5 ... ring args[]) { Recursia2 f = new Recursia2(); System.out.println("Факториал 5 равен " + f.factR(5)); } }

Recursion in java

Please explain how this recursion works, for example, if x takes 25: public static int pow(int x) { if (x==1) { return 1; } else { return pow(x / 2) + 1; } }

Recursive iterator

There is a recursive function for indexing directories and files. I need to create a hierarchical view of the file structure. ... enon? example of how to: 1-2-3-4-5-6-2-3-4-2-3 (ID numbers nodes). what happens: 1-2-3-4-5-6-7-8-9-10-11 And, yes, YAP - C#.

C / Recursive calculation of arctg(x)

You need to calculate arctg x using a recursive function and a continued fraction: With an accuracy of 0.000001. I do this: ... stem("pause"); return 0; } But I get thrown an exception about stack overflow. How to fix it and what exactly is wrong?

Sum of cubes by recursion - finding the best sum of cubes

def sumOfCubes(n): if n == 0: return sumOfCubes(n - (int(n ** (1/3))) ** 3) print((int(n ** (1 / 3)) ** 3), end=' ') su ... o it as the sum of cubes of other natural numbers. This sum must consist of the smallest number of terms among all such sums.

Recursive method in java. Where does the answer come from if it just returns itself?

I want to understand how the system understands that you need to display the value 4 on the screen? This method calculates th ... { if (q == 0) return p; int r = p % q; return gcd(q, r); } } OUTPUT: 4

Output of odd numbers via Python recursion

This is homework, but I can't do it in any way, I will be grateful at least for the advice =) The condition " Given a natural ... in descending order. " My code def rec(n): if n > 0: if n % 2 == 0: rec(n-1) print(rec(30))

Find the maximum of a one-dimensional array using recursion

During the course, I received a task: to implement a method for finding the maximum in an array recursively. Initially, I tri ... stion and I initially formulated it incorrectly. Thank you to the community for pointing this out to me and asking I'm sorry.

Evaluating an expression using recursion in c++

I tried to write my own function, but there are still problems: float findMain2(int n, int m = 1) { if (m == n) return ... sqrt(1 + (n + m) * findMain2(n, ++m)); } } In short, I don't understand why all the values of m change when increasing.

RecursionError: maximum recursion depth exceeded - how to overcome it?

There is a problem in the question ; there is a solution to it, where Python "won" C# by grace, but at the same time on x=512 ... erations, and for 2048 - "knocks out" the interpreter per 1000+ recursions. I don't understand what the problem is at all....

How to add a new array to the very end of a multidimensional array of arbitrary length in php

There is an array of arbitrary depth (up to several hundred attachments), where each element of the array is either another f ... derstand whether my function will bypass a multidimensional array, for example, with two (three, four, etc.) deep branches?

Array recursion in php

Please tell me how recursion works, and how to write such a function so that it can go through the entire array and delete a ... ey] === 'id_user') { unset($rules[$key]); } } return $rules; } That's how nothing comes out=(

What is the point of backtracking?

What does recursion have to do with it , and what is its role in backtracking ? Does it force the algorithm to return to the previous steps ? And what is backtracking ?

JavaScript recursion

I study JavaScript, recursion. Example from the tutorial. Problem: raising the number x to the natural power of n. In this e ... eturn x *= pow(x,n - 1); something is happening and where did this one come from -1?x *= pow(2,2); what happens next and why?

Creating an array from nested Python elements

Hello everyone Please help me develop an algorithm. There is a source list consisting of dictionaries: [ { 'A': ... the first elements on each level, and I didn't know how to make a recursion for each branch obtained as a result of grouping.