Question

Using python, please explain. The factorial of an integer N is the product of the integers...

Using python, please explain.

The factorial of an integer N is the product of the integers between 1 and N, inclusive. Write a while loop that computes the factorial of a given integer N.

Homework Answers

Answer #1
# Reading input number from user
N = int(input("Enter value for N: "))

# Initializing i to 1
# During the while loop value of i starts from i to N 
i = 1

# Initializing fact to 1
# The factorial is the product of value of i 
fact = 1

# Looping from 1 to N
while(i<=N):
    # multiplying fact with value of i
    fact = fact * i
    # incrementing the value of i
    i=i+1
# Printing the calculated factorial
print(fact)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For any integer n > 0, n!(n factorial) is defined as the product n * n...
For any integer n > 0, n!(n factorial) is defined as the product n * n - 1 * n − 2 … * 2 * 1. And 0! is defined to be 1 Create function that takes n as input and computes then returns the accurate value for: n!= n * n - 1 * n − 2 … * 2 * 1 prompt the user to enter an integer n, call functions to compute the accurate value for...
Be able to write Python programming of a factorial of an integer (given input parameters, output...
Be able to write Python programming of a factorial of an integer (given input parameters, output characteristics and expected output behavior, do not use internal python functions for factorials), recall for example that: 5! = 5 ∗ 4 ∗ 3 ∗ 2 ∗ 1 = 120 and to continue asking unless user says to stop NOT USING FACTORIAL FUNCTION
Write a program on C++ to calculate and print the factorial of a number using a...
Write a program on C++ to calculate and print the factorial of a number using a for loop. The factorial of a number is the product of all integers up to and including that number, so the factorial of 4 is 4*3*2*1= 24.
Write a MATLAB program to determine the factorial value of an input integer between 1 and...
Write a MATLAB program to determine the factorial value of an input integer between 1 and 30. You may NOT use the built-in factorial function. You must implement it using a for loop. Display the result back to the user with 2 decimal places (yes, 2 decimal places). The result should follow the following format:   The factorial value is *.xx
python a) Write a function, hailstone(), that takes an integer value n as a parameter, and...
python a) Write a function, hailstone(), that takes an integer value n as a parameter, and displays the hailstone sequence for the given integer. The hailstone sequence is determined as follows: if the value is even, divide by 2 (floor division) or if the value is odd, calculate 3 * n + 1. The function should display each value and continue updating the value until it becomes 1. b) Write a program to display the hailstone sequence of all integers...
Write a Python function that prints the numbers from 100 to 200 inclusive using a while...
Write a Python function that prints the numbers from 100 to 200 inclusive using a while loop. Thank you.
Write a Python function that prints the numbers from 100 to 200 inclusive using a while...
Write a Python function that prints the numbers from 100 to 200 inclusive using a while loop. Thank you.
Write a C program that asks the user to enter two integers x and n. Then...
Write a C program that asks the user to enter two integers x and n. Then the program computes xn (=x * x * x …… (n times)) using for loop. using printf scanf
Using Tuples in python In this problem, you will be given an array A of integers...
Using Tuples in python In this problem, you will be given an array A of integers of fixed size N and an integer K and you have to find the number of tuples (i, j) such that the following properties are satisfied, ● A[i]*A[i+1]*A[i+2]...A[j-1]*A[j] < K ● -1 < i < N ● i < j + 1 Note that the array is 0-indexed. Input Format The first line will contain integers N and K separated by a single space....
This is an exercise using a while loop Input an integer n from the keyboard. Calculate...
This is an exercise using a while loop Input an integer n from the keyboard. Calculate the sum of the first n integers. So if n=10, the answer should be 55 (because 1+2+3+4+5+6+7+8+9+10=55) Code language: Java
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT