七进制数

取模

function convertToBase7(num: number): string {
  let absNum = Math.abs(num)
  if (absNum === 0) return String(num)
  const ret: number[] = []

  while (absNum) {
    ret.push(absNum % 7)
    absNum = Math.floor(absNum / 7)
  }

  return (num > 0 ? '' : '-') + ret.reverse().join('')
}