Skip to content

Instantly share code, notes, and snippets.

Created December 8, 2017 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d4ae335299d03b8b964c3683976ecce8 to your computer and use it in GitHub Desktop.
Save anonymous/d4ae335299d03b8b964c3683976ecce8 to your computer and use it in GitHub Desktop.
/** 引数の平方根を求める関数. */
public static BigInteger sqrt(BigInteger terget) {
// 変数初期化
BigInteger num = BigInteger.ONE;
// ループ条件:対象 < 変数^2
while (terget.compareTo(num.multiply(num)) > 0) {
// num++
num = num.add(BigInteger.ONE);
}
return num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment