how to enumerate all permulations

dear there,

This seems like an easy one, but I haven't get it work yet -:)

I have 1747 bins, each bin can have number 1,2,...43, and I need to list all possible permutations. There are 43^1747 of them! Ideally the algorithm should list 1,1,...1 as the first output, followed by 1,1....,2, i.e., the permutation with small numbers should be generated first, since given a permutation I will evaluate another bool expression, and terminate on the first true. I wrote a recursive version and it doesn't work for such large number. Any suggestions? Thanks.