The interaction between the 5-fluorouracil anticancer drug and the purine bases of DNA and RNA was investigated by B3LYP method with the 6-311++G** basis set in the gas phase and water, carbon tetrachloride, acetone and methanol solvents and the geometric parameters, the interaction energy of and the vibrational frequencies associated with hydrogen bonding have been systematically explored. In order to better understand these hydrogen bonding interactions, the Bader’s quantum theory of atoms in molecules was used and the hydrogen bonding energy was calculated by the Spinoza method. . Also, single-point calculations were performed using M06-2x method with the same basis set mentioned in carbon tetrachloride and water solutions. The results showed that the interaction energy in this method has increased, but the order of stability of the hydrogen bonding complexes has not changed. It has been determined that strong hydrogen bonds are formed between monomers, which leads to changes in geometric parameters and electron structure of complexes. This subject was confirmed using electron density calculations. Comparison of the intervals and angles of hydrogen bonding showed that the hydrogen bond of N (O) B …H-NFU, in which 5FU acts as a proton donor, is stronger than the OFU … H-NB hydrogen bond. It was also observed that the hydrogen bond in the solvent with a hydrogen bond is weaker than the gas phase and the solvent without hydrogen bonding.