# How many combinations in 4 cell set with value 1-4?

I have a java array which contains four cells

A | B | C | D

Each cell can contain numbers 1-4, so for example:

1, 2, 3, 4

1, 1, 3, 4

1, 1, 1, 4

1, 1, 1, 1,

1, 1, 1, 2

And so on.

I'm trying to determine how many possible combinations there are, my algorithm is telling me over 200 and I'm not sure if there's a bug or that's the right number.

NOTE: Any number between 1 and 4 can occupy any of the cells, but there must be a number in each cell. So 1, 2, 3 is not a valid combination.

Thanks

• Your exampes are all in ascending order -- is that a restriction, or can each cell independently contain any of the numbers $1$ to $4$? Commented Mar 3, 2016 at 8:14
• why not $4^4$? any restriction? Commented Mar 3, 2016 at 8:15
• any number, no restriction Commented Mar 3, 2016 at 8:17
• there is a restriction, I edited. There must be a number in each cell. Commented Mar 3, 2016 at 8:23
• There are $4^4$ combinations, you don't need any algorithm for that. Commented Mar 3, 2016 at 8:27

By the rule of product, there are $4\cdot4\cdot4\cdot4=4^4=256$ different ways to fill the cells.