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

Factorial Program

EasyPython

Problem

Quest Global engineering tools need a small utility that computes factorial values for input calculations. Given a non-negative integer n, return n!, defined as the product of every integer from 1 through n.

Formal Specification

Implement factorial(n).

  • Input: An integer n where 0 <= n <= 20.
  • Output: An integer equal to n!.
  • Define 0! as 1.
  • Use an iterative approach. Do not use Python's built-in factorial function.

Constraints

  • 0 <= n <= 20
  • n is an integer
  • Return an integer result
  • Do not use Python's built-in factorial function

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.