Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Formula Needed for a Programming Issue?

I have two sets of variable combinations and I need a formula to find a result.

Knowns:

Number of items in A=2

Number if items in B=3

Total combinations: A*B = 6

If Item A values are 1 and 2

and Item B values are 1, 2 and 3

What formula would give me a range of 1-6 (total combinations)

Example Set

A B Result

1 1 =1

1 2 =2

1 3 =3

2 1 =4

2 2 =5

2 3 =6

The proof of the formula would be to have A=3 and B=4 where you end up with a new total combination of 3*4=12

The formula will be used in a programming application to resolve passed in values of A and B and use them to lookup a values in the result array (1-6).

Thanks in advance for all your help with this puzzle.

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    The following code works for VB

    N=0

    For X = 1 To 2

    For Y = 1 To 3

    N=N+1

    Print N & " " & X & Y

    Next Y

    Next X

    Forgot to code the numbers

    EDIT

    Change the upper value of X to 3 and the upper value of Y to 4 for 12 combinations.

Still have questions? Get your answers by asking now.