Your attempt to implement this in Mathcad Prime is::
Check all errors you made between the example function and your Prime functions, then the one thing that Prime complains about is that it does not like the n (defined as running from 1 to 100) inside the summation of Zdm1.
If you also add n as a parameter to the function, all errors are gone:
But, isn't it easier to rewrite the formula as it is given?
To simplify, I have set, previously n = q. If instead we set n different from q, the graphs do not change for n = 1 and n = 100, as seen in the following picture: