I\'m working on a homework problem that asks me this:
Tiven a finite set of numbers, and a target number, find if the set can be used to calculate the target number
Generally speaking, when you need to do something recursively it helps to start from the "bottom" and think your way up.
Consider: You have a set S of n numbers {a,b,c,...}, and a set of four operations {+,-,*,/}. Let's call your recursive function that operates on the set F(S)
F(S) will just be that number. F(S) can be eight things:
S (2 choices)x from S to be the left-hand operand (n choices)F(S-x)I'll let you take it from here. :)
edit: Mark poses a valid criticism; the above method won't get absolutely everything. To fix that problem, you need to think about it in a slightly different way:
S into two sets, for the left and right hand operands,F to both partitionsFinding all partitions of a set into 2 parts isn't trivial itself, though.