# Logop1134 factorial problem, logop1134 factorial

Source: Internet
Author: User

Logop1134 factorial problem, logop1134 factorial
Description

Maybe you have long known the meaning of factorial. N factorial is generated by multiplying 1 to N, for example:

12! = 1x2x3x4x5x6x7x8x9x10x11x12 = 479,001,600

The rightmost non-zero digit of the factorial of 12 is 6.

Write a program to calculate the value of the non-zero bits on the far right of the N (1 <=n <= 50,000,000) factorial.

Note: 10,000,000! There are 2499999 zeros.

Input/Output Format

Input Format:

Only one row contains a positive integer N.

Output Format:

A single row contains an integer representing the value of the non-zero digit on the rightmost side.

Input and Output sample input sample #1: Copy
`12`
Output example #1: Copy
`6`
Description

USACO Training Section 3.2

You cannot understand the solution.

Violence is acceptable.

`# Include <cstdio> int main () {long int N; scanf ("% lld", & N); long int now = 1; for (int I = 2; I <= N; I ++) {now = now * I; while (now % 10 = 0) now = now/10; now = now % 10000000 ;} printf ("% lld", now % 10); return 0 ;}`

Related Keywords:
Related Article

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.