I want to pick a random number and express that number in the format of a lottery system. For example, a lottery system has 7 groups of 2-digit numbers from 01 to 40 with the total possible combinations of 163,840,000,000 (40 to the 7th power). If I pick a random base-10 number, say 453,867,221, How can I express that in 7 groups of 2-digit numbers from 01-40?
My programming language of choice is Python, although any language/pseudo language will help.
So you have 40-base numbers with 7 40-base “digits”. Converting them to an integer is relatively simple (I’m using explicit loops to make things clearer):
Converting back is just the reverse: