Hacktorials - Hack factorials

2.5

12 votes
Problem

You have to take numbers as inputs until the user enters zero. Now with every number you take as an input, find its factorial (n!) , and find the reverse of that result and store it in an array. Now, display the array in the reverse order, once the user enters zero.

Constraints:

n<=17

Input

5

4

6

0

Explanation:

5!=120, reverse of 120=021, store it in A[0]

4!=24, reverse of 24=42, store it in A[1]

6!=720, reverse of 720 will be 027, store it in A[2]

Display the array, when it encounters zero.

Output

27

42

21

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?