将小数转换为混合基数(基本)
问题描述:
如何将十进制数转换为混合基数表示法?
How do you convert a decimal number to mixed radix notation?
我猜想给定每个基数数组的输入和十进制数,它应该输出每列值的数组.
I guess that given an input of an array of each of the bases, and the decimal number, it should output an array of the values of each column.
答
伪代码:
bases = [24, 60, 60]
input = 86462 #One day, 1 minute, 2 seconds
output = []
for base in reverse(bases)
output.prepend(input mod base)
input = input div base #div is integer division (round down)