Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- namespace _03.SquareRoot
- {
- class Program
- {
- public static decimal Sqrt(int number, decimal root)
- {
- if (Math.Abs(root * root - number) <= 0.00000000001M)
- return root;
- return Sqrt(number, root - ((root * root) - number) / (2 * root));
- }
- static void Main(string[] args)
- {
- decimal root = Sqrt(12345, 10);
- Console.WriteLine(root);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement