Can anyone help me understanding recursion and lowering its execution time?

I need it in this problem!

Consider the sequence of digits from 1 through N in increasing order: 1 2 3 ... N.

Now insert either a `+' for addition or a `-' for subtraction or a ‘ ‘to run the digits together between each pair of digits. Calculate the result that of the expression and see if you get zero.

Consider: 1-2 3-4 5+6 7. This translates to 1 – 23 – 45 + 67 = 0.

In: You will have an integer N (the last number of the sequence)

Out: Give all the possible solutions for this sequence.

I need it in this problem!

Consider the sequence of digits from 1 through N in increasing order: 1 2 3 ... N.

Now insert either a `+' for addition or a `-' for subtraction or a ‘ ‘to run the digits together between each pair of digits. Calculate the result that of the expression and see if you get zero.

Consider: 1-2 3-4 5+6 7. This translates to 1 – 23 – 45 + 67 = 0.

In: You will have an integer N (the last number of the sequence)

Out: Give all the possible solutions for this sequence.

maybe he mean about time efficiency while the program trying all the possible solutions...

CMIIW

CMIIW

Topic archived. No new replies allowed.