How many 0 are there in the mantissa of a 100!? 100 of the class really do not come out?

Source: Internet
Author: User

Today to see a pretty interesting question, is to ask "100!" "How many zeros are there in the mantissa?"

The mantissa has a number of 0, which actually refers to the number of the last not 0 of the number of the next (that is, 0) start counting, until the last number (these numbers are naturally 0) how many 0.

Well, that means 13330330000 of the mantissa has 4 0 ...

If an integer contains Factor 5, it must be solved in 100! Generates a 0, which means we start with a 5 for loop, plus 5 for Each loop, and then the counter adds 1. Also, if the integer is divisible by 25, the counter should be added to 1.

So the code looks like this:

#include<stdio.h>int main(){    int a,count =0;    for(a=5;a<=66;a+=5)    {        ++count;        if(!(a%25))            ++count;    }    printf("100!的尾数有%d个零。\n",count);    return0;}

After the topic further asked how to find out any n! How many zeros are in the mantissa.

#include <stdio.h>intMain () {intNprintf("Please enter n:\n"); scanf"%d", &n);if(n<0)printf("%d classes are meaningless. \ n ", n);Else if(n<=4)printf(The mantissa of the class%d has no zeros. \ n ");Else{intA,count =0; for(a=5; a<=n;a+=5) {++count;if(! (A%25)) ++count; }printf("100!" the mantissa has %d zeros. \ n ", count); }return 0;}

Is this the end of this article?

There is a passage in the answer to the question: first find the value of 100, and then count the number of zeros at the end. In fact, this is not possible because the range of integers the computer can represent is limited.

First, what is the range of integers that the computer can represent? The integer range of data types, such as int, is limited. To die can only be said to be unable to store and not to express.

Do the other 100 of the class really find out? Please read it down.

My blog has a lot of blog posts about Lisp, or scheme, and using this language, a few lines of code can be done, right? Welcome to my other blog posts ...

(define (fact n)  (if (= n 1)      1      (* n (fact (- n 1)))));Value: fact

1000 of the class can also ask for evidence ...

Idle bored, the following is 10000 of the class, we can continue to calculate a larger number, haha ...


I found this csdn blog to write so many numbers after the blog can not be submitted, there are anomalies ... No way, only upload ... After the download feel interesting remember to come back to praise Oh ...

Portal: 10000 of the class

How many 0 are there in the mantissa of a 100!? 100 of the class really do not come out?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.