Just one big program question for freshly baked interview questions

Source: Internet
Author: User

This afternoon, I went to the legendary ** interview. I had two questions and asked n! The number of 0 at the end of the result, for example, 18! = The number of zeros at the end of 6402373705728000 is 3.ProgramImplementation and complexity.

BelowCode:

Typedef unsigned _ int64 ty; ty getn (ty n) {If (n = 1) {return 1;} return N * getn (n-1 );} ty countzero (TY m) {If (M % 10! = 0) {return 0;} return 1 + countzero (M/10);} ty getzero (ty I) {return countzero (getn (I ));} ty getfuckzero (ty I) {return I/5;} int _ tmain (INT argc, _ tchar * argv []) {ty n = 18; printf ("% LlU! = % LlU-> % LlU \ n ", N, getn (N), getzero (N), getfuckzero (n); Return 0 ;}

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: info-contact@alibabacloud.com 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.