How can I use a variable as a power in C++
for example an equation n^n
should pow(n ,n) work?
I have a program for a class where a variable FIRST is the first number inputted from a file. I need to then work out the factorial using the equation
n! = e^(-n)*(n^n)*sqrt(2*pi*n)
Using FIRST as my variable instead of N I came up with the following equation:
FACTORIAL = (((pow(2.71828183, (-FIRST))) * (pow(FIRST, FIRST)) * sqrt(2 * 3.14159265 * FIRST)));
I am getting some overloading errors which I believe are due to the fact that I used a variable as the power instead of an integer?
How would one go about writing this equation using FIRST as my variable for N (FIRST happens to equal 6 if that makes any difference)?
This is my first C++ class so I am new to this. Any help would be great! thanks.