I am trying to make a program to calculate E.
I finished, but it kept returning
2.000000
I've looked over this code many times and I can't find an apparent problem.
Here is the code:
Code:
// e_calculate.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
int main()
{
printf("Enter an integer here\n/");
int num;
double e;
int factorial, count, count2;
count = 0;
count2 = 0;
factorial = 0;
scanf("%d", &num);
e = 1;
while (num > count)
{
count = count + 1;
factorial = count;
while (count > count2)
{
count2 = count2 + 1;
factorial = factorial * count2;
}
count2 = 0;
e = e + (1 / factorial);
}
printf("%f", e);
return 0;
}