Hi, I'm trying to write a program that can find out what the factors are for a certain number. We have to use the for loop and user defined functions are also part of what we are learning, but in this case I can't figure out how to define mt variables. The code I have written is not complete, it's just what I think is right. Any and all help is appreciated thanks!
/*In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,
6! = 6 x 5 x 4 x 3 x 2 x 1 = 720
The value of 0! is 1, according to the convention for an empty product.
Write a function to find the factorial of a number using the for loop.
Your function should take an integer n as input and returns n! as the result. Test your function by calling it in your main program.*/
#include <iostream>
#include <cmath>
using namespace std;
int factorial(int n)
int main()
{
int n;
cout << "Enter a whole number to find out numbers it can factor into:";
cin >>
factorial(n);
return 0;
}
int factorial(int n)
{
for(n <= )
}
just about every second or third person doing their first factorial problem tries to compute a value that is too large to fit in their data type and then thinks it is producing the 'wrong' answer. Keep in mind that even 100! (a relatively small input) is extremely large and won't fit in a standard integer.