Generating general term of union of two countably infinite sets I have two sets whose general terms are given as:
$$
\begin{align*}
A &amp;= \{2⋅n \mid n ∊ ℤ\} \\
B &amp;= \{2⋅n + 1 \mid n ∊ ℤ\}
\end{align*}
$$
I want to find the union of these two sets and return the common term of the set, something like $\{n \mid n ∊ ℤ\}$.

I have the following questions:


Given that I can't store the entire sets, what are some efficient ways of merging these two sets? 
How can I find the common term of any given sequence?
What would be some other approaches to solve this problem?


I would really appreciate if someone can share some
relevant literature or an algorithm for this question.

Note that the members of the sets need not be integers – they can be rationals too.
In functional programming languages, there is a technique called lazy evaluation, to deal with infinite sets. In lazy evaluation, the sets are used as generators, and the elements of the set are only generated when they are needed. 

We can even have lazy operations on lazy data: like lazy union, lazy intersection, and the like, particularly if the lazy generation spits out elements in some order. Particularly, lazy union is very efficient. Lazy intersection and lazy minus are problematic in cases such as yours.