package com.swu.math;
import java.math.BigInteger;
public class Test
{
public static String sqrt(String num)
{
BigInteger b=new BigInteger(num);
//不用多解释了吧
if(b.compareTo(BigInteger.ZERO)<0)
return "不是正数";
String sqrt="0"; //开方结果
String pre="0"; //开方过程中需要计算的被减数
BigInteger trynum; //试商,开放过程中需要计算的减数
BigInteger flag; //试商,得到满足要求减数的之后一个数
BigInteger twenty=new BigInteger("20"); //就是20
BigInteger dividend; ///开方过程中需要计算的被减数
int len=num.length(); //数字的长度
if(len%2==0) //长度为偶数
{
for(int i=0;i
{
dividend=new BigInteger(pre+num.substring(2*i,2*i+2));
for(int j=0;j<=9;++j)
{
trynum=twenty.multiply(n