0

Hello,

I am currently working off the sticky thread filled with practice problems etc. I have got a couple of the practice problems out of the way, and I am currently working on a program that will find the factoral of a number entered.

So far i have an array that will be filled with the numbers 1 - the number entered, I found a post from Narue that showed me how to find the length of the array, But how can i use that to multiply each element of the array by the next in order to get my factoral?

```
#include <iostream>
#define length(a) ( sizeof ( a ) / sizeof ( *a ) )
using namespace std;
void fact(int number);
int main() {
int number = 0;
cout << " Please enter a number to see its factoral: "<< endl;
cin >> number;
cin.ignore();
fact(number);
cin.get();
return 0;
}
void fact(int number){
int factorals[number];
int temp_total= 0;
int total = 0;
int total_facts = 0;
for(int i =0; i < number; i++){
factorals[i] = i;
}
total_facts = length (factorals);
for (int j=1; j <= total_facts; j++) {
temp_total = factorals[j] * (factorals[j]-1);
total = total + temp_total;
}
cout << " the Factoral is: " << total;
}
```

My problem is line 29 down. Obviously my math is way off, and i am getting completely wrong answers. any ideas?

Thanks for the help!