504, Base 7

동청·2022년 9월 4일
0

leetcode

목록 보기
19/39

Problem

leetcode 바로가기
Given an integer num, return a string of its base 7 representation.

Example 1:

Input: num = 100
Output: "202"

Example 2:

Input: num = -7
Output: "-10"

Constraints:

  • -107 <= num <= 107

Solution

/**
 * @param {number} num
 * @return {string}
 */
var convertToBase7 = function(num) {
    return parseInt(num, 10).toString(7)
};

0개의 댓글