# Tag Info

### Help!! How to do square root!

Java Wow, this is a complicated problem. I've never done a square root before. I've taken square roots, but I haven't done one. Don't forget to make your code look pretty for extra credit in your ...
• 20.9k

### Help!! How to do square root!

C++ Well, if you've got no better route, there's always the brute-force solution: ...
• 33.8k

### Help!! How to do square root!

Python 3 This simple code will give an exact answer: x = input('Enter a number: ') print('\u221A{}'.format(x))
• 6,511

### Help!! How to do square root!

In Python 3 you can do the following: def square_root(n): return float(n)**0.5
• 551

### Help!! How to do square root!

Correcting this answer, Using C, because C is fastest That's just plain wrong. Everyone knows that the fastest one is ASM. Pure x86_64 ASM! ...
• 9,472

### Help!! How to do square root!

Python Write a function or program that will "make a number square root". If it's allowed in your class you can use a complex mathematics library as a helper here, install it by running the ...
• 511

### Help!! How to do square root!

C Obviously this is the best way. It's as fast as you can imagine by looking at the code. Using C, because C is fastest, and this problem requires a fast solution. I've tested this for my favorite ...
• 11.8k

### Help!! How to do square root!

C Tricks and magics will make it work. ...
• 2,172

### Help!! How to do square root!

Python 3 You guys are doing it all wrong. Anyone can see that square root of 20 is not 4.47213595499958, or even √20. This solution moves the difficult task of calculating the square root to the ...
• 11.8k

### Help!! How to do square root!

JavaScript Unfortunately, JavaScript does not support the square root symbol for function names. Instead, we can use some other Unicode alphabet character to represent a square root function. In ...
• 4,940

### Help!! How to do square root!

Julia Obviously the best way to do it, its using the squared root Taylor Series: ...
• 642

### Help!! How to do square root!

Haskell I stopped trusting computers when I first heard about floating-point errors. I mean, seriously, if even Google can't get them under control, then who can? So our best bet is to find a ...
• 7,801

### Help!! How to do square root!

LaTeX The solution for this is pretty hard and very complex, so take your coffee. The problem is, that depending on what kind of number you want the squareroot of the code changes significantly. I'll ...
• 578

### Help!! How to do square root!

Java The most precise way to do this is to iterate. First, loop by integers until you go over the target, then switch over to ...
• 19.6k

### Help!! How to do square root!

Javascript These magic constants can be used to compute the square root of a number using the alphabet: ...
• 266

### Help!! How to do square root!

JavaScript/ActionScript There is no way to directly calculate a square root in either ActionScript or JavaScript, however, there is a workaround. You can get the square root of a number by raising it ...
• 1,178

### Help!! How to do square root!

JavaScript Very difficult problem ! There is no built-in function for that in JavaScript... Looks like a job for the Newton-Raphson solver. ...
• 12.1k

### Help!! How to do square root!

PHP (and others): Since the way that was described the question didn't meant that we actually need to calculate it, here is my solution: ...
• 7,347

### Help!! How to do square root!

Python 2.7 n = input("Enter a number which you want to make a square root: ") print "\u221A{} = {}".format(n**2, n) Explanation Quoting Wikipedia - Square ...
• 2,911

### Help!! How to do square root!

C++ based on http://en.wikipedia.org/wiki/Fast_inverse_square_root and @snack's answer. Except instead of bolting on a way to convert the x^(-0.5) into x^(0.5) I modified the algorithm to do it ...
• 24.8k

### Help!! How to do square root!

C This is better than all other 27 answers because those are all inaccurate. That's right, they only give one answer when there should be 2. This one doesn't even try to answer if it's going to be ...
• 181

### Help!! How to do square root!

E Note: this only works on my computer, as the underlying hardware does not store numbers in binary but in base e, such that what appears as 10 represents e, ...
• 245

### Help!! How to do square root!

JavaScript/HTML/CSS I thought about using jQuery and ids to troll a bit more, but I prefer vanilla js. The result is not perfectly precise, but it works ! ...
• 1,312

• 8,956

### Help!! How to do square root!

100% pure bash (integer based) With ascii-art presentation: This perfect root square have to be sourced in bash by using source command ...
• 2,924

### Help!! How to do square root!

Java Thanks, to ggmx's for code on generating n digits of pi in java. ...

### Help!! How to do square root!

JQuery this one is the most accurate (bonus: also works for letters!) Please enter the number : ...
• 2,008

### Help!! How to do square root!

C++ This will eventually get you a square root. ...
• 1,253