Story
The god of base is opening heaven’s gate for mortals to join the base party. You, as one of the believers, want to follow their steps to ascend to heaven.
But not everyone can get in.
The god posts this question to let you prove you are worthy of their party.
Task
You will get 2 inputs
- First being
X
which is a non-negative integer in base 10. - Second being
base
which is a list of bases to iterate over. - bases will always be positive integers which in range of 1~10
- The base will contain at least one not
1
base
You will need to present(print) X
in the form of iterating bases.
Example:
X ,[base] -> ans
6 ,[2] -> 110
It has only 1 base in base list, thus it converts number into base2
6 ,[2,4] -> 30
First base is 2, so 6%2=0 is the first digit and (6-0)/2 =3 is forwarded to next base.
Second base is 4, so 3%4=3 is the second digit and there is no remaining.
30 ,[2,3] -> 2100
First two digits come from 30%2=0, 15%3=0, with 15/3=5 is passed to next base,
which loops back to 2 => 5%2 = 1,pass 2=> 2%3 = 2
10 ,[9,2] -> 11
20 ,[3,4,5] -> 122
0 ,[any bases] -> 0
Rules
- No standard loopholes
- Input, output in any reasonable, convenient format is accepted.
The god requires short code—they will give access to the shortest code in each language. Fulfill their task to ascend!
42, [1]
? \$\endgroup\$