Python Factorial Challenge Day 3

Hello connections 👋 Welcome to Day 3 of my Python problem-solving series! Consistency is the key to growth, so here is today’s challenge 🚀 🧠 Day 3 Challenge: Find Factorial of a Number The factorial of a number n is the product of all positive integers less than or equal to n. 👉 Example: Input: 5 → Output: 120 (5 × 4 × 3 × 2 × 1 = 120) My Approach: Using Loop num = int(input("Enter a number: ")) fact = 1 if num < 0: print("Factorial does not exist for negative numbers") else: for i in range(1, num + 1): fact *= i print("Factorial =", fact) 📌 Explanation: We multiply all numbers from 1 to num. Now it’s your turn 👇 Try solving it with your own logic or suggest a better approach in the comments. Let’s learn and grow together 🚀 #Python #CodingChallenge #ProblemSolving #Programming #30DaysOfCode

To view or add a comment, sign in

Explore content categories