Questions tagged [square-root]

A square root of a number A is a number y such that y^2 = A, or, in other words, a number y whose square (the result of multiplying the number by itself, or y × y) is A.

A square root of a number A is a number y such that y2 = a, or, in other words, a number y whose square (the result of multiplying the number by itself, or y × y) is A.

398 questions
-3
votes
1 answer

How to calculate SquareRoot of Integer without using inbuilt function in Swift Language? I tried below code & searched but didn't get better solution

Just an exercise: func mySqrt(_ x: Int) -> Int { if x<2 { return x } var y = x var z = (y + (x/y)) / 2 while Double(abs(y - z)) >= 0.00001 { y = z z = (y + (x/y)) / 2 } return z } I went through many…
Renuka Pandey
  • 1,730
  • 2
  • 15
  • 27
-3
votes
1 answer

Python- Square Root of list

Taking the square root of each number in a list. For this problem in the sqrt_list function: Take the square root of each item in the list, Store each squared item in another list, and Return this list. alist = [11,22,33] def sqrt_list(alist): …
guest7238
  • 1
  • 3
-3
votes
1 answer

I created an algorithm that return the square root. Why it is not working?

My code is to working. I made an algorithm that takes a number, discover the base and the roof of the square root of this number( for exemplo, if I want to discover the square root of 5 then tha base will be 2 and the roof will be 5. That means the…
-3
votes
1 answer

Perfect Squares - Can someone explain following math?

Problem Statement: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2: Input: n = 13 Output:…
User1990
  • 161
  • 11
-3
votes
3 answers

Square root decrement from user input

After getting an integer from the user and finding the square root, I need to find the square root of every number from i to 0. I am having trouble figuring out how to properly decrement the input so it prints out the square root of each number in…
kuzman
  • 1
  • 3
-3
votes
1 answer

How is the logic reasoning done in these three codes?

def findRoot1(x, power, epsilon): low = 0 high = x ans = (high+low)/2.0 while abs(ans**power - x) > epsilon: if ans**power < x: low = ans else: high = ans ans = (high+low)/2.0 …
Eliza
  • 101
  • 1
  • 1
  • 9
-3
votes
1 answer

My c# program for square roots only works when the discriminant is 0 or less than 0, but not when it's greater than 0

private void btnCompute_Click(object sender, EventArgs e) { double coefficientA; double coefficientB; double coefficientC; double root1; double root2; double discriminant; coefficientA = double.Parse(txtCoeA.Text); …
Samantha
  • 3
  • 2
-3
votes
1 answer

C code explanation needed

Can someone explain the following code? what is the use of the variable ort? void squart_root(double a) { if (a>0.0){ double root = 1, ort = 0; while(ort!=root) { ort = root; root = ((a/root) + root) / 2; } …
-3
votes
3 answers

Calculating Square Root to 50 places

I'm doing a science fair project that tests five different square root algorithms to compute the square root of two. (see my question here). I have two options. Run each program for a set amount of time, and compare how close the end result is…
-3
votes
2 answers

BMI Calculator / Square root issue

I have an assignment in my first CSC class which is focused around Python 3. This is my second batch of code, so pardon if it's elementary. The assignment is to create a BMI calculator. A BMI is found by a person’s weight in (pounds) times 720.0 ,…
-4
votes
1 answer

how can I square the numbers between 0 and any input with extremely large numbers in python

I am in codewars and the challenge I have has one part I can't get my head around this is what I am speaking of You are given a number "n" (n >= 0) and a digit "d" (0 <= d <= 9). Write a function nbDig(n, d) that finds the square of each integer…
Logono
  • 5
  • 1
-4
votes
1 answer

Square Root in C

I want to get roots of many double type variables (with some operators in it) in a line of C. Example: In normal mathematics, √(b-a)2+(d-c)2 I had tried this in different ways, like #include #include int main() { int i,…
Tamim
  • 11
  • 1
  • 2
-4
votes
2 answers

How to do square root with Windows command processor using a batch file?

How in the world do I do square roots in batch? @echo off Title SquareRoot :SquareRoot cls echo Number: set /p number= set /a answer=sqrt %number% echo Number: %number% echo Answer: %answer% pause goto SquareRoot
-4
votes
3 answers

Java square root calculator?

Ok, I'm a beginner in java, learning on my own through websites and books. I tried a simple square root calculator with a for loop and a while loop (I've included what I tried below). Sadly, all my code does when I enter a number is terminate. Any…
-4
votes
2 answers

Why does math.sqrt return a float to one decimal point and not just the value wo the decimal point?

I'm not sure if this question has been answered(couldn't find it when I did a google search). I saw http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html that the math class square root method returns a double. I experimented with it in…
committedandroider
  • 8,711
  • 14
  • 71
  • 126
1 2 3
26
27