In mathematics, a square root of a number x is a number y such that y2 = x; in other words, a number y whose square (the result of multiplying the number by itself, or y ⋅ y) is x.
Calculate the floor of the square root of the input.
- type:
uint256 - range: unlimited
- type:
uint256
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.5;
library SampleSolution {
function sqrt(uint256 x) external view returns (uint256 y) {
// TO BE IMPLEMENTED
return 0;
}
}| input | output |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 1 |
| 12345 | 111 |