See the doc, it should be used this way:
public BigInteger mod(BigInteger m)
public BigInteger divide(BigInteger val)
You can change it to this:
factorialans.mod(BigInteger.valueOf(10))
and
factorialans.divide(BigInteger.TEN)
solved counting the zeros in the the factorial number, please the check the error