Ask Question
5 June, 22:38

In mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of n is the product of all the nonnegative integers from 1 to n. For example: 7! = 1 x 2 x 3 x 4 x 5 x 6 x 7 = 5,040 Write a program that lets the user enter a nonnegative integer and then uses a loop to calculate the factorial of that number. Print the factorial to standard output.

+4
Answers (1)
  1. 6 June, 00:13
    0
    The program to this question can be given as:

    Program:

    factorial=1 #declare a variable.

    number=int (input ("Enter a positive integer:")) #input a number.

    while (number>0) : #loop

    factorial = factorial*number # holding value in factorial variable

    number=number-1

    print ('=', factorial) #print value.

    Output:

    Enter a positive integer:6

    = 720

    Explanation:

    The description of the above python program can be given as:

    In the above program firstly we define a variable that is "factorial". In this variable, we assign a value that is 1 and it is used to calculate the factorial value. We define a variable "number". The number variable is used to take input from the user. Then we define a loop in the loop we calculate the factorial and hold the value in the factorial value in the last we print the value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “In mathematics, the notation n! represents the factorial of the nonnegative integer n. The factorial of n is the product of all the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers