Java BigInteger Value Check isPerfectCubic(BigInteger n)

Here you can find the source of isPerfectCubic(BigInteger n)

Description

is Perfect Cubic

License

Open Source License

Declaration

public static boolean isPerfectCubic(BigInteger n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;

public class Main {
    private static Map<BigInteger, Long> cubicCache = new HashMap<BigInteger, Long>();
    private static BigInteger maxCubicInCache = BigInteger.ZERO;

    public static boolean isPerfectCubic(BigInteger n) {
        while (maxCubicInCache.compareTo(n) < 0) {
            Long v = cubicCache.get(maxCubicInCache);
            ++v;//from  ww w.  j  av a 2 s  .c o  m
            BigInteger vb = BigInteger.valueOf(v);
            BigInteger k = vb.multiply(vb).multiply(vb);
            cubicCache.put(k, v);
            maxCubicInCache = k;
        }
        return cubicCache.containsKey(n);
    }
}

Related

  1. isMersenneNumber(BigInteger n)
  2. isNegative(BigInteger i)
  3. isNumberInRange(String text, BigInteger min, BigInteger max)
  4. isOdd(BigInteger in)
  5. isOdd(BigInteger x)
  6. isPositive(final BigInteger value)
  7. isPowerOfTwo(BigInteger bintValue)
  8. isPowerOfTwo(BigInteger x)
  9. isRootInQuadraticResidues(BigInteger n, BigInteger p)