Ask Question
8 February, 22:26

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.

+5
Answers (1)
  1. 8 February, 23:58
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers