Write a square root function that takes an input, positive or negative, and calculate it's square root, correct up to six decimal places (then truncate after the sixth decimal place). But, you cannot use ANY built in power related functions. This means nothing like (but not limited to):
Math.pow(n,0.5) sqrt(2) root(n,2) n**0.5 etc.
This means that you're going to have to use (or create) a method to find the square root. Two common methods are the Babylonian/bisector method and Newton's method, but feel free to create your own!
Output can be either printed to the console or returned. Your choice.
Input: sqrt(4) //you can call your function whatever you want Output: 2 Input: 7 Output: 2.645751 Input: 5.0625 Output: 2.25 Input: -15 Output: 3.872983i Input: -9 Output: 3i
This is code golf, so shortest code in bytes wins!
Remember, no built ins that have anything to do with powers!
If you have any questions, please, tell me in the comments and I'll clarify promptly.