Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Factorial Program
00:00
5 left

Factorial Program

EasyPython

Problem

Write a program to calculate the factorial of a number.

Implement def factorial(n):, which accepts a non-negative integer n and returns n!, where n! = n × (n - 1) × ... × 1. By definition, 0! equals 1. Return the result as an integer.

Constraints: 0 <= n <= 20.

Constraints

  • 0 <= n <= 20
  • n is an integer
  • The input is non-negative

Function Signature

def factorial(n):
Interviewer

Your question is Factorial Program. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.