Write a C-program which determines the numbers of
whose factorial values lie between 5000 to 32565?
Answers
Write a C-program which determines the numbers of whose factorial values lie between 5000 to 32565?
Explanation:
#include <iostream>
using namespace std;
int countFact(int low, int high)
{
// Find the first factorial number 'fact' greater than or
// equal to 'low'
int fact = 1, x = 1;
while (fact < low)
{
fact = fact*x;
x++;
}
// Count factorial numbers in range [low, high]
int res = 0;
while (fact <= high)
{
res++;
fact = fact*x;
x++;
}
// Return the count
return res;
}
// Driver program to test above function
int main()
{
cout << "Count is " << countFact(2, 720);
return 0;
}
Answer:
A whole number's factorial is the result of multiplying the integer by each natural number below it.
Explanation:
What is a Factorial ?
A positive integer and an exclamation point are used to represent the product of all positive integers that are less than or equal to the provided positive integer. Thus, factorial seven is denoted by the symbol 7!, which stands for 1 2 3 4 5 6 7. Factorial 0 is equivalent to 1 by definition.
A whole number's factorial is the result of multiplying the integer by each natural number below it. The sign "!" can be used to indicate a factorial symbolically. Therefore, "n factorial" is denoted by the number n and is the sum of the first n natural integers!
The value of the zero factorial, which is intriguing, is 1, or 0! = 1. Yes, the answer to the 0 factorial is 1, not 0.
// C++ Program to count factorial numbers in given range
#include <iostream>
using namespace std;
int countFact(int low, int high)
{
// Find the first factorial number 'fact' greater than or
// equal to 'low'
int fact = 1, x = 1;
while (fact < low)
{
fact = fact*x;
x++;
}
// Count factorial numbers in range [low, high]
int res = 0;
while (fact <= high)
{
res++;
fact = fact*x;
x++;
}
// Return the count
return res;
}
// Driver program to test above function
int main()
{
cout << "Count is " << countFact(2, 720);
return 0;
}
To learn more abot computer programming refer to :
https://brainly.in/question/9279803
https://brainly.in/question/6120371
#SPJ2