About 183,000 results
Open links in new tab
  1. How do I calculate square root in Python? - Stack Overflow

    Jan 20, 2022 · For example we need to find 30's square root. We know that the result is between 5 and 6. newtons_method(30,5) number is 30 and estimate is 5. The result from each …

  2. Is there a short-hand for nth root of x in Python? - Stack Overflow

    nth root of x is x^(1/n), so you can do 9**(1/2) to find the 2nd root of 9, for example. In general, you can compute the nth root of x as: x**(1/n) Note: In Python 2, you had to do 1/float(n) or …

  3. python - Square root calculation using bisection - Stack Overflow

    May 28, 2016 · I have the following code which should find the square root using bisection, but for some reason it won't ...

  4. Square root of number python - Stack Overflow

    Jan 4, 2015 · The result itself is correct. The square root of 25 + 0j is 5 + 0j. Where did the j come from ? Its implicit because you are using the complex math (cmath) library. If you only want the …

  5. python - Cube root modulo P -- how do I do this? - Stack Overflow

    Nov 7, 2014 · Here is the Python (2.6?) code for finding square roots: def modular_sqrt(a, p): """ Find a quadratic residue (mod p) of 'a'. p must be an odd prime. Solve the congruence of the …

  6. python - Check if a number is a perfect square - Stack Overflow

    Mar 22, 2010 · Use Newton's method to quickly zero in on the nearest integer square root, then square it and see if it's your number. See isqrt. Python ≥ 3.8 has math.isqrt. If using an older …

  7. square root of a number greater than 10^2000 in Python 3

    Dec 17, 2017 · The usual square root methods convert the parameter to a float value before doing the calculation. As you saw, this does not work well with very large integers. So use a function …

  8. math - Integer square root in python - Stack Overflow

    Mar 13, 2013 · Python's default math library has an integer square root function: math.isqrt(n) Return the integer square root of the nonnegative integer n. This is the floor of the exact …

  9. python - Better way to approximate the square root using …

    Jan 20, 2015 · If it is however more a question on how to calculate the square root algorithmically, you might consider binary search. Such binary search could use two stages: a stage to find an …

  10. python - Finding the square root using Newton's method (errors ...

    Dec 29, 2016 · I'm working to finish a math problem that approximates the square root of a number using Newton's guess and check method in Python. The user is supposed to enter a …

Refresh