Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Integer square root

    Integer square root

    Easybinary searchmath

    Return the square root of x rounded down, without built-ins like sqrt or **.

    Example 1

    Input:  x = 4
    Output: 2

    Example 2

    Input:  x = 8
    Output: 2

    The root is 2.82…, rounded down to 2.

    Constraints

    • 0 ≤ x ≤ 2³¹ − 1

    Submit checks your solution against 8 tests, including hidden ones.

    /**
     * @param {int} x
     * @return {int}
     */
    function mySqrt(x) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.