Maran Sowthri Kalailingam
Maran's Blog

Follow

Maran's Blog

Follow
Problem Solving

Problem Solving

Beginner

Maran Sowthri Kalailingam's photo
Maran Sowthri Kalailingam
·Feb 15, 2021·

2 min read

Problem

Write a program to find a factorial of a given number.

Examples

6! = 720, 5! = 120, 4! = 24

Dos

  • Try to solve it in a most simple and efficient way.
  • Share your codes in the comments (in any language), I'll find some bugs 😉.
  • Feel free to mention if you find any bugs in my code 🧐.
  • Share some challenges in the comments, I'll solve them in my next blog post.

Don'ts

  • Never see my code before solving it on your own.

Code

import math

num = 5
print(math.prod([i for i in range(1, num + 1)]))

I've used Python for solving this challenge, but if you want the same solution in some other languages let me know in the comments 👇.

 
Share this