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

struct{
	double a;
	double i;
	// c = a + i * b;
}typedef compl;

compl Exp(compl, int);
unsigned factorial(int);
void print_complex(compl z);

int
main()
{
	compl z = {4, 2};
	compl y = Exp(z, 13);
	print_complex(y);
	return 0;
}

unsigned 
factorial(int a)
{
	unsigned c = 1;
	for (int i = 1; i <= a; i++)
        c *= i;
	return c;
}

compl 
Exp(compl z, int n)
{
	compl x = {1, 1};
	for (int i = 1; i <= n; i++)
	{
		x.a += 1.0/factorial(i)*pow(z.a, i);
		x.i += 1.0/factorial(i)*pow(z.i, i);
	}
	return x;
}

void 
print_complex(compl z) {
    printf("%f + %fi\n", z.a, z.i);
}
