// Program: euler.cpp
// Approximate Euler's constant e.
#include
int main ()
{
// values for term i, initialized for i = 0
float t = 1.0f; // 1/i!
float e = 1.0f; // i-th approximation of e
std::cout << "Approximating the Euler constant...\n";
// steps 1,...,n
for (unsigned int i = 1; i < 10; ++i) {
e += t /= i; // compact form of t = t / i; e = e + t
std::cout << "Value after term " << i << ": " << e << "\n";
}
return 0;
}