Python Practice › List Programs › Program 77

Factorial of each item

EasyList Programs · 77 of 100

Write a Python program to get the factorial of each item in a list.

Advertisement
Input
[3, 4, 5, 6]
Output
[6, 24, 120, 720]

Approach

  1. math.factorial on each item.

Solution

Python
import mathprint([math.factorial(n) for n in [3, 4, 5, 6]])
Output
[6, 24, 120, 720]

Learn the concept

New to this topic? Read the lesson, then come back.

More list programs

← All 100 List Programs

Leave a Comment