×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# numbers that can differentiate uniquely between the combinations

## numbers that can differentiate uniquely between the combinations

(OP)
Hi forum users
I need a set of numbers that can differentiate uniquely between the combinations.I choose powers of 3. Starting with 1, that gives multiples of 1, 2 and 3 before I reach the next number, which is 3, with it having multiples of 3, 6, 9, etc. If I write out the combinations you can see what happens when you add them:

1 = 1 (eg. 1 Si)
2 = 1 + 1 (eg. 2 Si)
3 = 1 +
1 + 1 (e.g. 3 Si) or 3 (e.g. 1 Al) alone, and so now I have a problem, I can pick up 1 occurrence of the atom labelled 1, and two occurrences, but then one Al will give the same result as 3 Si. Since the Al atoms with their labels of 3 have multiples of 6, 9, etc, I'll never accidently find 4, 5 and/or 7/8, which I can only reach once I'm adding multiples of 1. With this set I can thus give a unique number to each possible combination of the two (but not three). I can pick any way forward, as long as you make sure that you get unique combinations every time.

Now Im stuck I want extend the assignment to 5 atoms : eg assigning a special number for other atoms like Mg,Ca, O and Na. Any one with a unique idea how can I do this. I want a code to be general so that It can be used for many things. I can assign atom name but my code wont be efficient and it will have many if statements.My assignments are shown in the code below.

[! Assign Si = 3**0 = 1, Al = 3**1 = 3 and unknown metals U = 3**2 = 9
! then we can identify pairs and triads easily without ordering
! [Si,Si] = 3**0 + 3**0 = 1 + 1 = 2
! [Si,Al] = [Al,Si] = 1 + 3 = 4
! [Al,Al] = 3 + 3 = 6
! [U,U] = 9 + 9 = 18
! [Al,U] = 3 + 9 = 12
! [Si,U] = 1 + 9 = 10
! [Si,Si,Si] = 1 + 1 + 1 = 3
! [Si,Si,Al] = 1 + 1 + 3 = 5
! [Si,Al,Al] = 1 + 3 + 3 = 7
! [Al,Al,Al] = 3 + 3 + 3 = 9
! [U,U,U] = 9 + 9 + 9 = 27
! [U,U,Si] = 9 + 9 + 1 = 19
! [U,U,Ai] = 9 + 9 + 3 = 21
! [U,Si,Si] = 9 + 1 + 1 = 11
! [U,Si,Al] = 9 + 1 + 4 = 14
! [U,Al,Al] = 9 + 3 + 3 = 15]

[do i = 1, natms
if (atmname(i) == silicon) then
id(i) = Si

elseif (atmname(i) == aluminium) then

id(i) = Al
else
id(i) = 9
endif
enddo

do i = 1, natms
do k = 1, nmetals
if (atmname(i) == metals(k)) then
do j = i, natms
if (atmname(j) == oxygen) then
bndtab(i,j) = mbonds(k)**2
bndtab(j,i) = bndtab(i,j)
endif
enddo
endif
enddo
enddo

endif
]

Then when I get the assignment correctly I want to use the code as this where I sect a correct or desired case as shown below.

[do i = 1, natms
if ((atmname(i) == oxygen) .and. (cnlist(i) .eq. 2)) then
select case ( id(blist(bindex(i))) + id(blist(bindex(i)+1)) )
case (2)
write(logfile,*)'[Si,Si] bridge'
nbo = nbo + 1
case (4)
write(logfile,*)'[Si,Al] bridge'
nbo = nbo + 1
case (6)
write(logfile,*)'[Al,Al] bridge'
nbo = nbo + 1
case (10)
write(logfile,*)'[Si,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (12)
write(logfile,*)'[Al,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (18)
write(logfile,*)'[Mg/Ca,Ca/Mg] disconnect'
end select
endif
]

### RE: numbers that can differentiate uniquely between the combinations

Curious problem...and I think you already found a solution to it...I can see a pattern.

If you are interested in combining any two atoms at a time, you can assign them numbers that are powers of 2; with the limitation that every atom can only appear once in a combination.

If you are interested in combining any 3 atoms at a time, you can assign them numbers that are powers of 3; with the limitation that every atom can only appear 2 times in a combination.

If you are interested in combining any 4 atoms at a time, you can assign them numbers that are powers of 4; with the limitation that every atom can only appear 3 times in a combination.

...and so on.

I think this way, every combination will have a unique number and to find out which atoms are part of the combination, you just start dividing by the largest number that you have assigned, see how many times it fits and work your way down with the residual and the next assigned number down.

### RE: numbers that can differentiate uniquely between the combinations

(OP)
Thanks Salgerman

Can you illustrate with an example so that I can see your approach for example demonstrate using this statement.If you are interested in combining any 3 atoms at a time, you can assign them numbers that are powers of 3; with the limitation that every atom can only appear 2 times in a combination.

The combination that appears two times its interesting. In my initial thinking,I thought about read,write and execute permissions (rwx) where r or w can only appear once not repeated. But Im interested in a situation where an atom can appear twice only as you stated.

Regards
Lehloks

### RE: numbers that can differentiate uniquely between the combinations

Powers of 2 are used extensively to put in a integer value a set of logical values (up to 32 in a 32bit integer), any combination becoming possible : for instance 7=2^0+2^1+2^2 means that the options 1 ,2 and 3 are all active (like read,write,execute for a file).

Depending on the number of atoms, you want to combine, I suggest to choose the highest possible value. For instance 10 !

Si=1
Al=10
U=100

5 => Si+Si+Si+Si+Si
11 => Al+Si
111 => U+Al+Si
...

François Jacq

### RE: numbers that can differentiate uniquely between the combinations

And what about using of primes factorization?
See here:
http://en.wikipedia.org/wiki/Fundamental_theorem_o...

For example there are these first 10 primes:
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

1. You can encode with it 10 chemical elements, e.g.:
Si = 2
Al = 3
U = 5
...
etc.

2. Then you can encode any combination of your elements, for example
4*Si, 1*Al, 2*U
into an integer number using the formula given in the link above:
N = 2**4 * 3**1 * 5**2 = 1200

3. You can decode the number using an factorization algorithm such like
http://en.wikipedia.org/wiki/Trial_division
and get back the primes - for example for N=1200 we get:
[2, 2, 2, 2, 3, 5, 5]
that is
4*2, 1*3, 2*5
looking at the encoding table above we have the combination
4*Si, 1*Al, 2*U

Here is my working prototype in Python - it could be possible to rewrite it in Fortran:

#### CODE

# Based on:
# http://en.wikipedia.org/wiki/Trial_division
def trial_division(n):
"""Return a list of the prime factors for a natural number."""
if n == 1: return [1]
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
prime_factors = []

for p in primes:
if p*p > n: break
while n % p == 0:
prime_factors.append(p)
n /= p
if n > 1: prime_factors.append(n)

return prime_factors

if __name__=="__main__":
# create a number
n = 2**3 * 3 * 5**2

# factorize number
primes=trial_division(n)
print primes

# create a number
n = 2**4 * 3**1 * 5**2 # = 1200

# factorize number
primes=trial_division(n)
print primes 

Output:

#### CODE

\$ python factorisation.py
[2, 2, 2, 3, 5, 5]
[2, 2, 2, 2, 3, 5, 5] 

### RE: numbers that can differentiate uniquely between the combinations

(OP)
Thanks a lot guys

With these Ideas I can also be able to work out how long my Si and Al polymer chains. I like the most mikrom Idea.But one more question just for interest is it possible to work out the combination in advance because of systems with varrying number of atoms one of them is 2377 atoms = N

thanks a lot.

### RE: numbers that can differentiate uniquely between the combinations

#### Quote (lehloks)

just for interest is it possible to work out the combination in advance because of systems with varrying number of atoms one of them is 2377 atoms = N
I don't understand what you mean with 2377 atoms, please specify it.
I found out that there are only 118 chemical elements:
http://en.wikipedia.org/wiki/List_of_elements

If you will have 118 chemical elements and want to use the prime factorizatione method, you will need the first 118 prime numbers - see http://en.wikipedia.org/wiki/List_of_prime_numbers

Then the resulting numbers for encoding your elements combination could be very huge, so maybe you will have technical problems using build in integer types ...

The factorization of huge numbers using the trial division method would be hard, because of its exponential complexity, so maybe you will have to search for more efficient method ...

I suggest to try the approach first on a smaller number of elements and see how it works and if it fullfil your expectations.

### RE: numbers that can differentiate uniquely between the combinations

(OP)
"just for interest is it possible to work out the combination in advance because of systems with varrying number of atoms one of them is 2377 atoms = N"
Sorry for this!
I meant system size made up of 2377 atoms,with 5 atom types.

### RE: numbers that can differentiate uniquely between the combinations

For encoding 5 elements, you only need first 5 prime numbers: [2, 3, 5, 7, 11]
IMO it will be OK.

### RE: numbers that can differentiate uniquely between the combinations

That's bate and switch!...you first innocently talk about combining 3 atoms at a time and now you are talking a chain 2000 long! Not cool...you should have given a hint of your needs from the beginning

Assigning unique ID for every atom using powers of (n+1) where n is the maximum number of times you want a given atom to be able to appear in the combination gets a bit crazy quick...now that you mention that an atom may have to appear hundreds or even a thousand times in a combination. For example, if you want an atom be able to appear 999 times in a combination, you would need to assign ID to atoms as powers of 1000...for 5 atoms involved in the combination, their IDs would be 1000, 1000000, 1000000000, 1000000000000, 1000000000000000. And the summation of these numbers hundreds of times will get very large. The main problem with this approach is the exponential growth of ID and, consequently, the large gap of unused IDs in between consecutive IDs...for a final combination ID being a very large number.

I too like the prime number approach. In that case, the gap between unused IDs is rather small, keeping all IDs also small...the only problem is that the final combination ID is no longer the summation of ID, but the multiplication of their exponentiation...this is going to get large, too, if any one of them needs to be raised to the 1000 power!

If you assign permanent IDs to each atom and you have 118 of them, possibly in the same order as the periodic table, some will necessarily get assigned a rather large prime number that when raised to a power of 800 it is going to be a rather large number. This approach allows you to have unique IDs for every combination, but the combination IDs will get unnecessarily large or impossible to store as numeric value.

One way to alleviate the problem above is to not limit yourself to specifying combinations via a single attribute (unique ID), instead, create a structure and include the list of atoms that are going to be part of the combination and assign to this atoms the first few prime numbers and that is it...combination numbers would be unique on a per set-of-atoms-involved basis....even 2**1000, though, is large.

Any particular reason why you are not simply using strings? : "(1602*H)(800*C)"
• they can be put together easily and consistently...need to develop strategy of listing atoms in alphabetical or atomic-weight order or something.
• they can be easily compared
• they would be unique
• no need to worry about storage of very large numbers
gsal

### RE: numbers that can differentiate uniquely between the combinations

One more thing...have you google or visited chemical-engineering forums? molecular-analysis forums? or something? I am thinking you are not the first looking into this problem and there may already exist some software out there for this kind of task...talk about Python...I think I have seen some molecular analysis module.

### RE: numbers that can differentiate uniquely between the combinations

(OP)
Hi gsal

Yes its combination of 3 atoms because im interested in bonding angles, bond lengths, and other short range order properties which takes place between 2 to 3 atoms. I raised the issue of chain because microm suggestion gave an idea that I can also look at how long the chains are, which is what im trying to do now from his suggested solution. What you saying its true I realised earlier that the no increases exponentially as you increase the no of atoms. Also the gap becomes too large and jump other atoms when you used too large numbers.

### RE: numbers that can differentiate uniquely between the combinations

I thought that you mean the total number of combinations should be possible up to 2377.
But maybe you mean that one element may occur in one combination 2377 times? In this case if you want to encode the combination of 2377*Si, then you will get a very large number, i.e. 2**2377. Then you have to search for the specialized library for working with large numbers ... maybe something for cryptography.

Just for curiosity: why do you thing, that you need to encode the element combination into one number?

For example, a simple approach would be to define for every element an array which holds the occurence:

#### CODE

integer, dimension (maxN) :: Si, Al, Mg, Ca, U
then when you have for example these combinations

#### CODE

1. 4*Si, 1*Al, 2*U
2. 2377*Si
... 
your arrays will have following values:

#### CODE

Si(1)=4   , Al(1)=1, Mg(1)=0, Ca(1)=0, U(1)=2
Si(2)=2377, Al(2)=0, Mg(2)=0, Ca(2)=0, U(2)=0
... 

### RE: numbers that can differentiate uniquely between the combinations

(OP)
Hi microm
I atoms which are not bonded,I put them in a box,then I run an MD simulation,they react and form bonds, I know the likes bonds. I have already observed them using my other code. I also abserved the formation of triads Si-Al-Mg forming in my system. Now there is a competion between Mg and Ca, I want to determine the number of Si-Al-Mg and Si-Al-Ca formed in the system. From this I can tell and use the available theory to confirm the most likely reaction to take place.

Instead of what you suggesting which I think its also a good idea 'integer, dimension (maxN) :: Si, Al, Mg, Ca, U ' I have used a verlet list to determine atoms which are closer to each other.

### RE: numbers that can differentiate uniquely between the combinations

(OP)
Here I have included bits of the code,In the first part I assign a unique number to the atoms, then combine them, then use the combination at a later part of the code. Now I want to assign unique numbers to Ca and Mg and use them as shown below in the code

[! Assign Si = 3**0 = 1, Al = 3**1 = 3 and unknown metals 3**2 = 9
! then we can identify pairs and triads easily without ordering
! [Si,Si] = 3**0 + 3**0 = 1 + 1 = 2
! [Si,Al] = [Al,Si] = 1 + 3 = 4
! [Al,Al] = 3 + 3 = 6
! [U,U] = 9 + 9 = 18
! [Al,U] = 3 + 9 = 12
! [Si,U] = 1 + 9 = 10
! [Si,Si,Si] = 1 + 1 + 1 = 3
! [Si,Si,Al] = 1 + 1 + 3 = 5
! [Si,Al,Al] = 1 + 3 + 3 = 7
! [Al,Al,Al] = 3 + 3 + 3 = 9
! [U,U,U] = 9 + 9 + 9 = 27
! [U,U,Si] = 9 + 9 + 1 = 19
! [U,U,Ai] = 9 + 9 + 3 = 21
! [U,Si,Si] = 9 + 1 + 1 = 11
! [U,Si,Al] = 9 + 1 + 4 = 14
! [U,Al,Al] = 9 + 3 + 3 = 15

do i = 1, natms
if (atmname(i) == silicon) then
id(i) = 1

elseif (atmname(i) == aluminium) then

id(i) = 3
else
id(i) = 9
endif
enddo

do i = 1, natms
do k = 1, nmetals
if (atmname(i) == metals(k)) then
do j = i, natms
if (atmname(j) == oxygen) then
bndtab(i,j) = mbonds(k)**2
bndtab(j,i) = bndtab(i,j)
bndtab(j,i) = bndtab(i,j)
endif
enddo
endif
enddo
enddo

endif
]

second part of the code:this where I use the

[ nbo = 0
nnbo = 0
ntbo = 0
call cpu_time(tstart)
! [Si,Si] = 3**0 + 3**0 = 1 + 1 = 2
! [Si,Al] = [Al,Si] = 1 + 3 = 4
! [Al,Al] = 3 + 3 = 6
! [U,U] = 9 + 9 = 18
! [Al,U] = 3 + 9 = 12
! [Si,U] = 1 + 9 = 10
do i = 1, natms
if ((atmname(i) == oxygen) .and. (cnlist(i) .eq. 2)) then
select case ( id(blist(bindex(i))) + id(blist(bindex(i)+1)) )
case (2)
write(logfile,*)'[Si,Si] bridge'
nbo = nbo + 1
case (4)
write(logfile,*)'[Si,Al] bridge'
nbo = nbo + 1
case (6)
write(logfile,*)'[Al,Al] bridge'
nbo = nbo + 1
case (10)
write(logfile,*)'[Si,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (12)
write(logfile,*)'[Al,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (18)
write(logfile,*)'[Mg/Ca,Ca/Mg] disconnect'
end select
endif
]

### RE: numbers that can differentiate uniquely between the combinations

Use
[code ] [/code ]
tags for enclosing the code

### RE: numbers that can differentiate uniquely between the combinations

(OP)
[/[! Assign Si = 3**0 = 1, Al = 3**1 = 3 and unknown metals 3**2 = 9
! then we can identify pairs and triads easily without ordering
! [Si,Si] = 3**0 + 3**0 = 1 + 1 = 2
! [Si,Al] = [Al,Si] = 1 + 3 = 4
! [Al,Al] = 3 + 3 = 6
! [U,U] = 9 + 9 = 18
! [Al,U] = 3 + 9 = 12
! [Si,U] = 1 + 9 = 10
! [Si,Si,Si] = 1 + 1 + 1 = 3
! [Si,Si,Al] = 1 + 1 + 3 = 5
! [Si,Al,Al] = 1 + 3 + 3 = 7
! [Al,Al,Al] = 3 + 3 + 3 = 9
! [U,U,U] = 9 + 9 + 9 = 27
! [U,U,Si] = 9 + 9 + 1 = 19
! [U,U,Ai] = 9 + 9 + 3 = 21
! [U,Si,Si] = 9 + 1 + 1 = 11
! [U,Si,Al] = 9 + 1 + 4 = 14
! [U,Al,Al] = 9 + 3 + 3 = 15

do i = 1, natms
if (atmname(i) == silicon) then
id(i) = 1

elseif (atmname(i) == aluminium) then

id(i) = 3
else
id(i) = 9
endif
enddo

do i = 1, natms
do k = 1, nmetals
if (atmname(i) == metals(k)) then
do j = i, natms
if (atmname(j) == oxygen) then
bndtab(i,j) = mbonds(k)**2
bndtab(j,i) = bndtab(i,j)
bndtab(j,i) = bndtab(i,j)
endif
enddo
endif
enddo
enddo

endif]

[/second part of the code:this where I use the
nbo = 0
nnbo = 0
ntbo = 0
call cpu_time(tstart)
! [Si,Si] = 3**0 + 3**0 = 1 + 1 = 2
! [Si,Al] = [Al,Si] = 1 + 3 = 4
! [Al,Al] = 3 + 3 = 6
! [U,U] = 9 + 9 = 18
! [Al,U] = 3 + 9 = 12
! [Si,U] = 1 + 9 = 10
do i = 1, natms
if ((atmname(i) == oxygen) .and. (cnlist(i) .eq. 2)) then
select case ( id(blist(bindex(i))) + id(blist(bindex(i)+1)) )
case (2)
write(logfile,*)'[Si,Si] bridge'
nbo = nbo + 1
case (4)
write(logfile,*)'[Si,Al] bridge'
nbo = nbo + 1
case (6)
write(logfile,*)'[Al,Al] bridge'
nbo = nbo + 1
case (10)
write(logfile,*)'[Si,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (12)
write(logfile,*)'[Al,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (18)
write(logfile,*)'[Mg/Ca,Ca/Mg] disconnect'
end select
endif
]

### RE: numbers that can differentiate uniquely between the combinations

No, lehloks, you need to write the entire sequence of left-bracket,the word 'code' (w/o apostrophies) and right-bracket BEFORE your source code; then, AFTER your source code you finalize it with a similar bracket-'code'-bracket, this time, though, you precede the word 'code' with a slash '/'.

OR

you can highlight your source code and then click on the "code formatting" icon in the bar along the top of the editing window...it is between the guy with a message box and the wrapped gift.

### RE: numbers that can differentiate uniquely between the combinations

(OP)

#### CODE

[/[! Assign Si = 3**0 = 1, Al = 3**1 = 3 and unknown metals 3**2 = 9
! then we can identify pairs and triads easily without ordering
! [Si,Si] = 3**0 + 3**0 = 1 + 1 = 2
! [Si,Al] = [Al,Si] = 1 + 3 = 4
! [Al,Al] = 3 + 3 = 6
! [U,U] = 9 + 9 = 18
! [Al,U] = 3 + 9 = 12
! [Si,U] = 1 + 9 = 10
! [Si,Si,Si] = 1 + 1 + 1 = 3
! [Si,Si,Al] = 1 + 1 + 3 = 5
! [Si,Al,Al] = 1 + 3 + 3 = 7
! [Al,Al,Al] = 3 + 3 + 3 = 9
! [U,U,U] = 9 + 9 + 9 = 27
! [U,U,Si] = 9 + 9 + 1 = 19
! [U,U,Ai] = 9 + 9 + 3 = 21
! [U,Si,Si] = 9 + 1 + 1 = 11
! [U,Si,Al] = 9 + 1 + 4 = 14
! [U,Al,Al] = 9 + 3 + 3 = 15

do i = 1, natms
if (atmname(i) == silicon) then
id(i) = 1

elseif (atmname(i) == aluminium) then

id(i) = 3
else
id(i) = 9
endif
enddo

do i = 1, natms
do k = 1, nmetals
if (atmname(i) == metals(k)) then
do j = i, natms
if (atmname(j) == oxygen) then
bndtab(i,j) = mbonds(k)**2
bndtab(j,i) = bndtab(i,j)
bndtab(j,i) = bndtab(i,j)
endif
enddo
endif
enddo
enddo

endif]

[/second part of the code:this where I use the
nbo = 0
nnbo = 0
ntbo = 0
call cpu_time(tstart)
! [Si,Si] = 3**0 + 3**0 = 1 + 1 = 2
! [Si,Al] = [Al,Si] = 1 + 3 = 4
! [Al,Al] = 3 + 3 = 6
! [U,U] = 9 + 9 = 18
! [Al,U] = 3 + 9 = 12
! [Si,U] = 1 + 9 = 10
do i = 1, natms
if ((atmname(i) == oxygen) .and. (cnlist(i) .eq. 2)) then
select case ( id(blist(bindex(i))) + id(blist(bindex(i)+1)) )
case (2)
write(logfile,*)'[Si,Si] bridge'
nbo = nbo + 1
case (4)
write(logfile,*)'[Si,Al] bridge'
nbo = nbo + 1
case (6)
write(logfile,*)'[Al,Al] bridge'
nbo = nbo + 1
case (10)
write(logfile,*)'[Si,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (12)
write(logfile,*)'[Al,Ca/Mg] disconnect'
nnbo = nnbo + 1
case (18)
write(logfile,*)'[Mg/Ca,Ca/Mg] disconnect'
end select
endif
] 

### RE: numbers that can differentiate uniquely between the combinations

Another option is to consider bit patterns based on frequency. Say Si can occur up to 30 times, U up to 100 times, Al up to 50 times. You can use 8 byte integers which should take you up to 64 bits. Beyond that, you'll have to use a different technique.

First round up to the nearest multiple of 2

Si 30 => 32 - 5 bits - bits 0..4
U 100 => 128 - 7 bits - bits 5..11
Al 50 => 64 - 6 bits - bits 12..16

#### CODE --> Pictorially

17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
<--     Al    --> <--      U       --> <--   Si   --> 

The initial value will be the base value - 2 to the lowest bit number

Si 2**0 = 1
U 2**5 = 32
Al 2**12 = 4096

So U,Al,Al would be 32 + 2 * 4096.
To work out what a pattern has,

#### CODE

integer:: elem(3)
character*2:: mnem(3)
mnem(1) = 'Si'
elem(1) = 1 ! Si
mnem(2) = 'U '
elem(2) = 32 ! U
mnem(3) = 'Al'
elem(3) = 4096 ! Al
! working out what is in x
rem = x
do ii = 3, 1, -1
if (rem .ge. elem(ii)) then
! Work out how many
howmany = rem / elem(ii)
rem = mod(rem, elem(ii))
do jj = 1, howmany
end do
end if
end do
write(*,*) 
Not sure if this is what you're looking for

### RE: numbers that can differentiate uniquely between the combinations

For ease, record keeping purposes and uniqueness, I would vote for ditching this idea powers and prime numbers and having a single unique integer as the identifier of a combination...I don't even see the point of it...it is not like you can do math with them like meaningfully subtracting two combinations and get a third one or anything like that.

So, I would simply use arrays or, rather, a single 2D matrix...

The first index of the matrix (row number) would be the i-th combination; the second index (column number) would be the atom...the value in the (i,j) position would be, given the i-th combination, how many times the j-th atom participates in it. As simple as that. So, this matrix would have as many rows as you care to have combination and as many columns as there are elements in the periodic table (118).

With the 2D matrix, you will have at all times the exact composition of each combination, no need to decode anything.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!