CodeTestValidate

No installations needed! Write Python directly in your browser and get instant feedback with our smart validation system.

Challenge # 9

Find Square Root Without math.sqrt

Objective

Calculate the square root of a number without using built-in math functions.

Instructions

  • You are given a non-negative number n.

  • Your task is to find and print the square root of n.

  • Do not use math.sqrt or any similar built-in function.

  • You may use simple iterative methods like binary search or the Newton-Raphson method.

  • Print the square root rounded to 5 decimal places.

Constraints:
Do not use input(). • Do not use math.sqrt or any similar built-in method. • `n` will be a non-negative float or integer.
Exemple IO

Input: n = 25

Output: 5.00000

Input: n = 2

Output: 1.41421

Input: n = 0

Output: 0.00000

Try It Online!

Output:

Validate Your Results

Get your code reviewed and validated to understand what you did right and where you can improve.

Previous challengeCheck AnagramsNext challengeCapitalize First Letter of Each Word
Loading...