Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] The Nearest Square Number by vincent.tscherter
"use strict";
function nearestSquare(number) {
return Math.pow(Math.round(Math.sqrt(number)),2);
}
var assert = require('assert');
if (!global.is_checking) {
//console.log('Example:')
//console.log(nearestSquare(8))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(nearestSquare(8), 9)
assert.equal(nearestSquare(13), 16)
assert.equal(nearestSquare(24), 25)
assert.equal(nearestSquare(9876), 9801)
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
May 25, 2018