We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Although this is in javaScript and javaScript does not work well with large numbers(up to 53 bits) here is my version of your code in javaScript:
function checkBeauty(num) {
var str = num.toString();
var numLen = str.length;
var firstNum = 0;
var incre = 0;
var testStr = '';
if (numLen <= 1) {
return 'NO';
}
for (var i = 1; i <= numLen/2; i++) {
firstNum = parseInt(str.substr(0, i));
testStr = firstNum.toString();
incre = firstNum;
while (testStr.length < numLen && str != testStr) {
// this part needs help in javaScript because it only works up to 53bits
incre++;
testStr += incre.toString();
}
if (testStr == str) {
break;
}
}
return testStr == str ? 'YES ' + firstNum : 'NO';
Separate the Numbers
You are viewing a single comment's thread. Return to all comments →
thank you @johnpearson.
Although this is in javaScript and javaScript does not work well with large numbers(up to 53 bits) here is my version of your code in javaScript:
function checkBeauty(num) {
}