Ctrl K

Whole Square Root

Easy
You are given a non-negative integer number. Return the whole part of its square root, that is, the largest integer r ≥ 0 such that r · r ≤ number. Built-in power and root helpers are off limits: no number ** 0.5, math.sqrt, math.isqrt or pow. Get there with comparisons and integer arithmetic alone.
Example 1
number=49 → 7

7 · 7 = 49, so the root is exact.

Example 2
number=50 → 7

The square root of 50 is about 7.07; dropping the fraction leaves 7.

Example 3
number=0 → 0
Constraints
  • 0 ≤ number ≤ 2³¹ − 1
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Lost Ticket EasyTiles Into a Full Square EasyFull Pyramid Rows EasyDigit of Endless Counting MediumA Base of All Ones Hard
loading Python…
Input
number=49
Expected
7

Run checks the first 3 tests in your browser. Submit checks all 59 tests on the server, hidden ones included.