Purely algebraic algorithms are proposed for solving aspheric singlets and cemented doublets with desired focal length and primary aberrations. Singlets can meet the focal length, spherical aberration and central coma; cemented doublets can even meet the longitudinal chromatic aberration. An aspheric surface can be defined by either a conic or a fourth-order aspheric coefficient. In some situations, conic surfaces must be adopted to satisfy the required aperture diameters. They may have one or multiple aspheric surfaces and the aberration equations indicate that these aspheric coefficients of different surfaces are linearly dependent. Four examples including a classical front-stop singlet landscape lens, a DVD-rewritable (DVD-RW) pickup head lens, a singlet with double conic surfaces, and a cemented doublet in a telescope system are demonstrated.