Hacker News new | past | comments | ask | show | jobs | submit login

I believe it would be 7290, or more generalized, S(N) = 10 * 9 ^(N-1) with N being the length of the code and S being the number of combinations (assuming that a decimal system is used)

And from there, with variable lengths ranging from L to H, S(L, H) = 5/4 * 9 ^(L-1) * (9^(U-L+1) - 1)

So if the bank allows combinations from 4 - 6 digits, there would be a total of 663390 combinations to choose from.

Now, of course, the bank may decide to go from decimal to hexadecimal in the future - or maybe, there systems allow only duodecimal. In any case, the formula can be generalized further to account for all number systems - with B being the base of the system:

S(L, H, B) = (B/(B-2)) * (B-1) ^(L-1) * ((B-1)^(U-L+1) - 1)

This is only defined for B > 2 - in binary system, there's only ever two combinations which fit the constraint




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: