In this article, a numerical method is developed to solve the linear integrodifferential equations. To this end, it will be divided in two forms, Fredholm integro-differential equations (FIDE) and Volterra integro-differential equations (VIDE). So that, the kernel and other known functions have been approximated using the least-squares approximation schemes based on Legender-Bernstein basis. The Legender polynomials are orthogonal and this property improve the accuracy of the approximations. Also the unknown function and its derivatives have been approximated by using the Bernstein basis. The useful properties of Bernstein polynomials help us to transform integro-differential equations to solve a system of linear algebraic equations. Of course, the solution way of (FIDE) case is different from (VIDE).