Jump to content

Math/Statistics Problem - Possible Combinations of Number Sequance - Need Help


siteturbo

Recommended Posts

Hello All:

 

I've been trying this for the last 3 or 4 days and haven't figured it out yet.  Any help would be appreciated.

 

THE PROBLEM:

 

I am trying to output a sequence or combination numbers, from say, 1 through 5 using only the digits 1 through 5, and all their possible combinations.

Example #1:

 

digits 1, 2, 3

 

The possible combinations are...

 

1,2,3

1,3,2

2,1,3

2,3,1

3,2,1

3,1,2

 

Example #2:

 

digits 1, 2, 3, 4

 

The possible combinations are...

 

1,2,3,4

1,2,4,3

1,3,2,4

1,3,4,2

1,4,2,3

1,4,3,2

2,1,3,4

2,1,4,3

and so on...

 

HINT...

 

I know that each solution should have n! (n factorial) solutions.  In other words, for 3 digits (numbers 1 through 2), there are 3! solutions, or 3x2x1 = 6 solutions.  For 4 digits, there are 4! solutions, or 4x3x2x1 = 24 solutions.  And so on.

 

I would like to be able to plug in a number, say "X", and get all combinations of all numbers form 1 to "X".

 

I've tried nesting for loops, trying using one for loop with multiple expressions, etc.  However, no success.

 

Anyone with a lot of brain power want to give it a shot?!

 

Thanks a bunch!

 

--

Ed

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.