My Math Forum  

Go Back   My Math Forum > High School Math Forum > Algebra

Algebra Pre-Algebra and Basic Algebra Math Forum


Reply
 
LinkBack Thread Tools Display Modes
May 17th, 2010, 06:21 PM   #1
Newbie
 
Joined: May 2010

Posts: 2
Thanks: 0

find unique n number combination in total n number

Hi all,

I have a math question related to my programming problem.
It is best to describe in scenario:

find all possible x digit number in range(1 to y) (no-repeat)

find all possible 1 digit number in 1-6 (no-repeat)
answer = 1,2,3,4,5,6

find all possible 2 digit number in 1-6 (no repeat) (eg. 12, and 21 are the same)
answer = 12,13,14,15,16
= 23,24,25,26
= 34,35,36
= 45,46
= 56

find all possible 3 digit number in 1-6 (no repeat) (eg, 123 and 321 are the same)
answer = 123, 234, ... and so on


I'm stuck in these, I need to come out with a formula as the x and y can be plug in


Any help will be much appreciated!

Thanks in advance
jsonliu is offline  
 
May 17th, 2010, 07:26 PM   #2
Global Moderator
 
The Chaz's Avatar
 
Joined: Nov 2009
From: Northwest Arkansas

Posts: 2,766
Thanks: 4

Re: find unique n number combination in total n number

The number is the binomial coefficient. (http://en.wikipedia.org/wiki/Binomial_coefficient)
To find all of the possible x-digit numbers would (obviously) require an algorithm. What have you tried?
The Chaz is offline  
May 18th, 2010, 04:39 AM   #3
Newbie
 
Joined: May 2010

Posts: 2
Thanks: 0

Re: find unique n number combination in total n number

Quote:
Originally Posted by The Chaz
The number is the binomial coefficient. (http://en.wikipedia.org/wiki/Binomial_coefficient)
To find all of the possible x-digit numbers would (obviously) require an algorithm. What have you tried?
Does not look like that, anyway I've found the solution perhaps it can help others

http://www.sonyjose.in/blog/?p=62
jsonliu is offline  
May 18th, 2010, 05:01 PM   #4
Member
 
Joined: Apr 2010

Posts: 65
Thanks: 0

Re: find unique n number combination in total n number

PARI/GP
Code:
f(c,z,b,n,k)={
        if(z<b,
                print1(c" ");
                if(n,
                        f(c+1, z  , b*k    \n, n-1, k-1 ));
        ,  /* else */
                if(n,
                        f(c+1, z-b, b*(n-k)\n, n-1, k   ));
        );
}

comb(n,k)={
	for (i=0,binomial(n,k)-1,
		print1(i") ");
		f(1,i,binomial(n-1,k-1),n-1,k-1);
		print1("\n");
	);
}

comb(6,2)
  • 0) 1 2
    1) 1 3
    2) 1 4
    3) 1 5
    4) 1 6
    5) 2 3
    6) 2 4
    7) 2 5
    8 ) 2 6
    9) 3 4
    10) 3 5
    11) 3 6
    12) 4 5
    13) 4 6
    14) 5 6
binomial(n,k)=
binomial(6,2)=6/1*5/2
binomial(6,3)=6/1*5/2*3/3
Xitami is offline  
Reply

  My Math Forum > High School Math Forum > Algebra

Tags
combination, find, number, total, unique



Search tags for this page
Click on a term to search for related topics.
Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Total number of combinations crone Advanced Statistics 5 July 26th, 2013 01:01 PM
What is the total number of string in ?* muhammadmasood Computer Science 7 September 14th, 2012 01:03 PM
Number of unique after n samples BigBugBuzz Advanced Statistics 3 December 15th, 2010 02:25 PM
The total number of pairs of integers? Kenzo Algebra 14 August 13th, 2009 12:29 PM
Find minimum number of possible combination shalinisharma512 Number Theory 3 April 4th, 2009 12:56 PM





Copyright © 2017 My Math Forum. All rights reserved.