Q:

function keeps returning NaN

Hi guys i know what NaN(let me say i know the acronym stands for Not a Number) is but i don't understand why C++ returns it - The following is the approximation of the mathematical constant e - When using the debugger the functions evaluate fine, it's when writing to the console that it returns NaN
Thanks for any feedback
double Factorial(int k)
{
    if(k == 0)
        return 1;

    int value = 1;
    for(int i = k; i > 0; i--)
        value *= k;
    return value;
}

double e(int p)
{
    double value = 0.0;

    for(int i = 0; i < p; i++)
    {
        value += 1/Factorial(i);
    }
}

A:

You don't return a value in your e function.

