Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5594 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3412 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 783 |

@Manikanta punnam | 605 |

@sriramgoparaju99 | 586 |

@rdakka | 538 |

@praveenbgp6 | 529 |

@prankursharma31 | 518 |

@yashkaril4 | 517 |

@purohitmn02 | 467 |

@sonamnigam1999 | 443 |

@sonamkumari63928 | 441 |

@shubhamstudent5 | 433 |

Complete Leaderboard |

You are given an array **A** of integers of length **N**. You need to calculate factorial of each number. The answer can be very large, so print it modulo **10 ^{9 }+ 7**.

**Example 1:**

**Input:
**N = 5
A[] = {0, 1, 2, 3, 4}
**Output:**
1 1 2 6 24
**Explanation:**
Factorial of 0 is 1,
factorial of 1 is 1, factorial of 2 is 2,
factorial of 3 is 6 and so on.

**Example 2:**

**Input:
**N = 3
A[] = {5, 6, 3}
**Output:**
120 720 6
**Explanation:**
Factorial of 5 is 120,
factorial of 6 is 720,
factorial of 3 is 6.

**Your Task:**

Complete the function **factorial()** which takes** **list** a **and single integer **n**, as input parameters and returns a list of factorials of the numbers in the list a.

**Expected Time Complexity:** O(max(A) + N)

**Expected Auxiliary Space:** O(max(A))

**Constraints:**

1 <= N <= 10^{5}

0 <= A[i] <= 10^{5}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Large Factorial

...