All the syntax is good, it just doesnt do what I want to do.Code:#include <iostream> #include <cmath> using namespace std; // Stirling's Formula :::: e^(-n) * n^(n) sqrt(2)(PI)(n) // n = 18 const int PI = 3.14; double n; double r; int main() { int stirling1, stirling2; cout << "Enter a number for n! : "; cin >> n; "Enter a number for r! : "; cin >> r; for (n; n > 1; n++) { stirling1 = n; stirling2 = r * (n-r); double CalcStirling = stirling1 / stirling2; cout << "Stirling's string is : " << CalcStirling << endl; return 0; } }
Im trying to have n be 18 and calculate the factorial of that and r be 6 and have the factorial calculated. But it will not calculate. I type any # in for "n" and it shows it, but then you type in anything for "r" and it just returns 0.
Can anyone help me here so that it lets you input a value for both "n" and "r" and then returns the right result ?
Im VERYY new to C++ so please forgive me . Thanks




Reply With Quote