katiebreon2297 katiebreon2297
  • 18-01-2021
  • Computers and Technology
contestada

Write a Python function that takes a positive integer N and returns the factorial of N, i.e., N! The factorial of N, denoted N!, is the product of the integers from 1 to N. (1 Point)

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 20-01-2021

Answer:

The python function is as follows:

def fact(N):

   factorial = 1

   for i in range(1,N+1):

       factorial = factorial * i

   return(factorial)

Explanation:

This line defines the function

def fact(N):

This line initializes the product of 1 to N to 1

   factorial = 1

This line iterates through 1 to N

   for i in range(1,N+1):

This line calculates the product of 1 to N i.e. factorial

       factorial = factorial * i

This line returns the factorial

   return(factorial)

Answer Link

Otras preguntas

Answer the following questions using words from your vocabulary list. Be careful with the spelling and accent marks so you'll get an accurate score. Include the
list 6.318 6.32 6.230 6.108 greatest to least
a major renaissance work by machiavelli was
5 facts about the vacuole
The lest common multiple of a number n and 6 is 42. What are of the possible whole number values for n?
explain how and why relations between Native Americans and Spain were different from relations between the Native Americans and France.
We elect one-third of the Congress every two years. a. True b. False
How do you write out 506709 in word form?
What is a substrate?
Answer the following questions using words from your vocabulary list. Be careful with the spelling and accent marks so you'll get an accurate score. Include the