Simplifying products

58 Views Asked by At

Sorry for the very general title, but I don't even know how to name my question.

I got a formula which is:

$f(n)=\prod_{i = 0}^{\infty} ((n \; \mathrm{rem} \; p^{i + 1}) \; \mathrm{div} \; p^i + 1) $

or alternatively

$f(n)=\prod_{i = 0}^{k} ((n \; \mathrm{rem} \; p^{i + 1}) \; \mathrm{div} \; p^i + 1) $

Being n a natural number, and p a prime. "rem" refers to the remainder and "div" is floor division.

Is there a way to simplify this expression, especially in order to reduce its computational cost (when implemented on a machine)?