计算阶乘数中的零,请检查错误

counting the zeros in the the factorial number, please the check the error

编译错误

Main.java:18: error: method mod in class BigInteger cannot be applied to given types;
r = factorialans.mod(10);
                        ^
required: BigInteger
found: int
reason: actual argument int cannot be converted to BigInteger by method invocation conversion
Main.java:22: error: method divide in class BigInteger cannot be applied to given types;
            factorialans = factorialans.divide(10);
                                       ^
  required: BigInteger
  found: int
  reason: actual argument int cannot be converted to BigInteger by method invocation conversion
2 errors

import java.util.Scanner;
import java.math.BigInteger;

class Main  {
    public static void main(String args[]) {
        BigInteger r;
        BigInteger factorialans=new BigInteger("1");

        int n,i,count=0;
        Scanner sc=new Scanner(System.in);
        n = sc.nextInt();
      //factorial...
        for (i = n; i > 0; i--){
            factorialans = factorialans.multiply(BigInteger.valueOf(i));
        }

            System.out.print(factorialans);

        while(!factorialans.equals(0)){
          r = factorialans.mod(10);
            if (r.equals(0)){
                count++;
            }
            factorialans = factorialans.divide(10);
        }
        System.out.print(count);
    }
}

看到doc,应该这样使用:

public BigInteger mod(BigInteger m)

public BigInteger divide(BigInteger val)

你可以改成这样:

factorialans.mod(BigInteger.valueOf(10)) 

factorialans.divide(BigInteger.TEN)