Seeking an efficient way to calculate $\sum_{k=2}^n\frac{1}{a_k}$ in a computer program, where the $a_k$ are integers stored in a vector I need an efficient way to compute sums of reciprocal of numbers using a computer program. Currently, I have a set of integers $\{a_{0}, a_{1}, \ldots a_{n}\}$, and I want to compute 
$$\sum_{i=0}^{n} \frac{1}{a_{0}}$$
as a fraction.
I know what $n$ is. Is there a good way to do this? For example, if $n = 1$, it's just $1/a_{0}$. If $n = 2$, it's $(a_{0} + a_{1})/(a_{0} \cdot a_{1})$. 
But, it gets more complicated for $n = 3$. 

More specifically, I'm writing a computer program to compute the sum $S$ given by 
$$S = \sum_{k=2}^{N} \frac{1}{v(k)u(k)}$$
where $v(k)$ and $u(k)$ are guaranteed to be integers. I don't think what the functions are doing actually matters for my question, but $v(k)$ represents the largest prime $p$ that does not exceed $k$, and the function $u(k)$ represents the smallest prime strictly greater than $k$. Also, $N$ is passed in as a parameter. Currently, I've stored each of the products of $v(k)u(k)$ in a vector.

To repeat myself, from another site, on a different problem:
The way I'd do it? Build a class representing fractions. Obviously, this class would have two integer fields for the numerator and denominator.
Methods to implement:


*

*Reduction to lowest terms. Find the gcd of the numerator and denominator, and divide both by it. Swap signs if necessary so that the denominator becomes positive. This one's behind the scenes - you should never need to call it from the outside, only from other methods.

*A constructor, that takes a pair of integers as input and gives you that fraction.

*Arithmetic. The problem technically only calls for addition, but subtraction and multiplication aren't any harder. Division or inverses call for error handling, if you go there.
If you're going to reuse this for other purposes, some other things like comparison would be worthwhile. I was thinking in Java terms when I wrote this originally; the details of the jargon might change, but the concepts will be there in any standard programming language.
