How many ways to make 20

How many ways can you make 20 by using 1,5,7,8, and 10?
One easy way I can think of:

5 + 5 + 5 + 5 = 20

What other way/s you can devise?

Please show us what you have tried and exactly where you are stuck.

Please follow the rules of posting in this forum, as enunciated at:


Please share your work/thoughts about this problem.
 
(5x5x8)/10

Can you repeat numbers? Do you have to use all the number? What operations can you use (multiplication, division, addition, subtraction, powers, factorials, ...)? Can you use parenthesis.

You want us to play this game with you but you did not give us the rules!
 
I'm going to take initiative and pretend that the rules are as follows:
  • The numbers 1, 5, 7, 8 and 10 are available.
  • A combination is formed by selecting one or more of these numbers together.
  • A satisfying combination is one where the sum of the constituent numbers is 20.
  • Equivalent combinations with the same numbers but different ordering are not considered distinct.
I did this because I wanted to make another silly brute force program in JavaScript. Without considering equivalent combinations non-distinct, it was taking too long because of the [MATH]5^{20}[/MATH] or so combinations to consider. Instead, I had to work out a way to produce only combinations with different selections of the available numbers.

Provided I did it correctly, the total number of distinct combinations (including the ones that don't sum to 20) is 53,129. Off the top of my head I don't know a simple formula for reaching this total, but I assume there must be one and I welcome anyone's insights. The number of combinations that do sum to 20 is quite small. Is there a formula to find that number as well?

Here is my code:
JavaScript:
// Available numbers
let numbers = [ 1, 5, 7, 8, 10 ];

// Process all distinct combinations of numbers
for (let set = [ 0 ]; set.length < 21;) {

    // Calculate the total sum of the current combination
    let total = 0;
    for (let x of set)
        total += numbers[x];

    // The current combination sums to 20
    if (total == 20) {
        let output = [];
        for (let x of set)
            output.push(numbers[x]);
        console.log(output);
    }

    // Advance to the next combination
    for (let x = 0; x < set.length; x++) {

        // Select the next number
        set[x]++;

        // The number is in the list of available numbers
        if (set[x] < numbers.length) {

            // Set all previous elements to the current number
            for (let y = x - 1; y >= 0; y--)
                set[y] = set[x];

            break;
        }

        // All elements in the list are the last available number
        if (x == set.length - 1)
            set.push(-1); // Add a new element to the list

    }

}
 
Top