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.
You will get 2 inputs
- First being
Xwhich is a non-negative integer in base 10.
- Second being
basewhich 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
You will need to present(print)
X in the form of iterating bases.
X ,[base] -> ans 6 , -> 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
- 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, ? \$\endgroup\$