标签:algo number UNC console list fun cti rem lock
125, how to conver to binary number?
function DecimalToDinary (n) { let temp = n; let list = []; if (temp <= 0) { return ‘0000‘; } while (temp > 0) { let rem = temp % 2; list.push(rem); temp = parseInt(temp / 2, 10); } return list.reverse().join(‘‘); } console.log(DecimalToDinary(125)) // 1111101
[Algorithm] Convert a number from decimal to binary
标签:algo number UNC console list fun cti rem lock
原文地址:https://www.cnblogs.com/Answer1215/p/10846926.html