Abstract. One of the most important steps in a Kohn-Sham (KS) type density functional theory calculation is the construction of the matrix of the KS operator (the “Fock” matrix). It is desirable to develop an algorithm for this step that scales linearly with system size. We discuss attempts to achieve linear scaling for the calculation of the matrix elements of the exchange-correlation and Coulomb potentials within a particular implementation (the Amsterdam density functional, ADF, code) of the KS method. In the ADF scheme the matrix elements are completely determined by 3D numerical integration, the value of the potentials in each grid point being determined with the help of an auxiliary function representation of the electronic density. Nearly linear scaling for building the total Fock matrix is demonstrated for systems of intermediate size (in the order of 1000 atoms). For larger systems further development is desirable for the treatment of the Coulomb potential.