Here is an answer I recieved on yahoo.com:

Yahoo! Answers - Do you have a formula for this word puzzle?
Interestingly, it uses Pascal's Triangle to solve the problem:

Ron Allen (person who answered the question to my satisfaction):

let n be the max value for any wheel.

for example n=2 would give you 0,1, or 2 for each wheel

my simplification involves 2 things

first it involves the progression of numbers (i forget what the specific name for it is - johnphantom comment: this is known as Pascal's Triangle, see

All You Ever Wanted to Know About Pascal's Triangle and more) . The progression can be depicted as a triangle with the number 1 at the top

the next row would have 2 numbers 1,1

the next row would have 3 numbers 1,2,1

the next row would have 4 numbers 1,3,3,1

the next row would have 5 numbers 1,4,6,4,1

and so on

this progression gives you the multiplier for each term in the simplification and the row number that you use is equal to the number of wheels in the lock

the terms in the simplification are as follows

for 1 wheel the first and only term is n+1

for 2 wheels the first term is n+1 the second is n^2

for 3 wheels the first term is n+1 2nd is n^2 3rd is n(n-1)^2

for 4 wheels 1st is n+1 2nd is n^2 3rd is n(n-1)^2 4th is n(n-1)(n-2)^2

for 5 wheels the 5th term is n(n-1)(n-2)(n-3)^2

and so on

the terms are simply summed with their multipliers so in your example you get:

(1)(n+1) + (3)(n^2) + (3)(n(n-1)^2) + (1)(n(n-1)(n-2)^2)

so plugging in 4 for n you get 5+48+108+48=209

if you had the numbers 0 tru 5 on each wheel you'd get

6+75+240+180=501

3 numbers and 3 wheels?

(1)(n+1) + (2)(n^2) + (1)(n(n-1)^2)

4+18+12=34

the only limitation here is that n >= the number of wheels.

Here are the formulas for five and six wheels/numbers:

five: (1)(n+1) + (4)(n^2) + (6)(n(n-1)^2) + (4)(n(n-1)(n-2)^2) + (1)(n(n-1)(n-2)(n-3)^2)

six: (1)(n+1) + (5)(n^2) + (10)(n(n-1)^2) + (10)(n(n-1)(n-2)^2) + (5)(n(n-1)(n-2)(n-3)^2) + (1)(n(n-1)(n-2)(n-3)(n-4)^2)

Anyone else find this interesting?