  We present an N-body computer code - aimed at studies of galactic dynamics -
with a CPU-efficient algorithm for a continuous (i.e. time-dependent) stellar
mass-loss. First, we summarize available data on stellar mass-loss and derive
the long-term (20 Gyr) dependence of mass-loss rate of a coeval stellar
population. We then implement it, through a simple parametric form, into a
particle-mesh code with stellar and gaseous particles. We perform several tests
of the algorithm reliability and show an illustrative application: a 2D
simulation of a disk galaxy, starting as purely stellar but evolving as
two-component due to gradual mass-loss from initial stars and due to star
formation. In a subsequent paper we will use the code to study what changes are
induced in galactic disks by the continuous gas recycling compared to the
instantaneous recycling approximation, especially the changes in star formation
rate and radial inflow of matter.
