EMA (period) = alpha * period.price + (1 - alpha) * EMA (period.previous)
alpha is a smoothing factor that can be expressed as alpha = 2 / (n - 1) where n is the number of periods under consideration. This n does not limit the number of perios over which the EMA is calculated. n periods accounts for 85% of the total EMA.
If we want x% of the total EMA then select k = log ((100.0 - x) / 100.0) / log (1 - alpha) or k = 3.45 * (n + 1).