Realization of universal computing units for nanorobots is highly promising in creating new and wide arrays of applications, particularly in the realm of distributed computation. However, such realization is also a challenging problem due to the physical limitations of nanometer-sized designs such as in computation, sensory and perception as well as actuation. This paper proposes a theoretical foundation for solving this problem based on a novel notion of distributed swarm computing by basis agents (BAs). The proposed BA is an abstract model for nanorobots that can compute a very simple basis function called B-function. It is mathematically shown here that a swarm of BAs has the universal function approximation property and can accurately approximate functions. It is then analytically demonstrated that a swarm of BAs can be easily reprogrammed to compute desired functions simply by adjusting the concentrations of BAs in the environment. We further propose a specific structure for BAs which enable them to perform distributed computing such as in the aqueous environment of living tissues and nanomedicine. The hardware complexity of this structure aims to remain low to be more reasonably realizable by today technology. Finally, the performance of the proposed approach is illustrated by a simulation example.