FCTRL2 - Small factorials


You are asked to calculate factorials of some small positive integers.

Input

An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100.

Output

For each integer n given at input, display a line with the value of n!

Example

Sample input:
4
1
2
5
3

Sample output:

1
2
120
6

hide comments
muf_f1n: 2020-05-24 20:36:20

Don't use any library functions in this function... that's the goal of this problem

shreya_nawani: 2020-05-21 21:37:22

try bigint for java or c++

tezu_singh: 2020-05-20 05:11:30

use boost library ,learn it from tutorial point and do simple factorial

Last edit: 2020-05-20 05:12:38
sakibmalik: 2020-05-08 12:17:24

spoilers for c++ users:
use string for multiplying and storing large numbers(may be just write a function for multiplying digit by digit)
<duh! obvious>

Last edit: 2022-09-17 23:08:56
sarastic_19: 2020-05-06 22:03:55

why this code work in python? not in c++.

rahul_521: 2020-04-18 15:26:55

For C++, we can just use multiprecession library :)

a_h_n_a_f_41: 2020-04-09 14:19:05

well!java bigint rocks!

nahid_180103: 2020-03-08 18:40:31

alhamdulillah AC first submit in C

lordvidex: 2020-02-23 00:26:26

why does python work excellently for this problem but C++ just can't? Is there a tweak to expanding the limit of numbers beyond long long int?

sandipan2224: 2019-12-02 19:20:23

Why isn't recursion working for large numbers?


Added by:adrian
Date:2004-05-28
Time limit:1s
Source limit:2000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All