Small factorials Solved Problem code: FCTRL2, factorialsfctrl2

Source: Internet
Author: User

Small factorials Solved Problem code: FCTRL2, factorialsfctrl2

1 import sys 2 3 4 def fact (n): 5 final = n 6 while n> 1: 7 final * = n-1 8 n-= 1 9 return final # logic rigorous, do not forget return10 11 12 def main (): 13 t = int (sys. stdin. readline () 14 for n in sys. stdin: 15 print fact (int (n) # Reading String conversion is a common pitfall 16 17 18 main ()

// Second, use a ready-made Library

1 from math import factorial # Familiar with this call method 2 3 4 def main (): 5 t = int (raw_input () 6 for I in range (t ): 7 print factorial (int (raw_input () 8 9 10 main ()

 

Learning

How to call external Libraries

Error

The function forgot return, and the idea was not rigorous.

I forgot to convert the data type during reading.

The conversion of the py type is more important than that of the C

 

Related Article

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.