Counting trailing zeros of numbers resulted from factorial

后端 未结 10 1693
北荒
北荒 2020-11-30 07:48

I\'m trying to count trailing zeros of numbers that are resulted from factorials (meaning that the numbers get quite large). Following code takes a number, compute the facto

10条回答
  •  借酒劲吻你
    2020-11-30 08:39

    You can use a DecimalFormat to format big numbers. If you format your number this way you get the number in scientific notation then every number will be like 1.4567E7 this will make your work much easier. Because the number after the E - the number of characters behind the . are the number of trailing zeros I think.

    I don't know if this is the exact pattern needed. You can see how to form the patterns here

    DecimalFormat formater = new DecimalFormat("0.###E0");
    

提交回复
热议问题