Warning: Completely new to Stack Overflow, so any tips on asking questions so I can help the people answering are appreciated.
I've come to the conclusion that I need to factorize, decompose, or implement some type of branching process to get the results I want. Please correct me if I am wrong, I am here to learn.
I've sourced that from two different StackOverflow answers.
Decompose integers larger than 100 digits
https://softwareengineering.stackexchange.com/questions/195813/generating-random-math-expression
I am working on a problem but I don't have the math background to completely understand the appropriate solution. So more than just an answer, but any reference to skills I can pick up to learn myself would be awesome.
What I am expecting is an algorithm which I can use to generate the results.
So here is what I want to happen.
Say I have a integer, 56.
I want to be able to generate a random math expression of a finite size which equals 56. This expression should be limited to 4 operators; Add, Subtract, Multiply, Divide.
So the equation I expect as a result of this algorithm is;
Input: integer 56, length 4
Results:
10 + 2 x 3 + 20 = 56
another example
Input: integer 34, length 5
3 * 7 / 2 * 3 + 4 = 34
Some notes I should fill you in on. I want to be able to generate these random expressions from an integer I provide, at a length I determine. The order of operators aren't important. I don't want to generate an equation without knowing the results randomly as I need to know the results prior to execution for efficiency. You will also notice in the second example, if the whole numbers are treated as floats, the equation would be incorrect. I decidedly want the individual operations to floor results, or round to the previous integer rather than introduce a decimal point. I am not 100% I want to round down, but let me know your thoughts on handling rounding.
I have a few ideas of how to do this myself, but I really would like second eyes on this to understand this problem on an academic level.
If it isn't already obvious, I am self taught. Thanks for your answers! I hope to be apart of this amazing community.