#include <stdio.h>
#include <math.h>

double exp_taylor(double x) {
	int i;
	double s, t;

	s = 0;
	t = 1;
	i = 1;
	while (1) {
		s += t;
		if (fabs(t) < fabs(s) * 1e-15) {
			break;
		}
		t *= x / i;
		i++;
	}
	return s;
}

int main()
{
	printf("%.17g\n", exp_taylor(20.));
	printf("%.17g\n", exp(20.));

	printf("%.17g\n", exp_taylor(-20.));
	printf("%.17g\n", exp(-20.));

	printf("%.17g\n", 1. / exp_taylor(20.));
}
