An ionic compound is formed from positive and negative ions which have balanced and opposite charges.K has 1 electron in it's outer shell. S has 6 electrons in it's outer shell. S needs 2 more electrons to fill it's outer shell and become more stable. K can only lose 1 electron so 2 atoms of K are needed. Each of the 2 atoms of K lose 1 electron each and become +1 ions. Both of these electrons are gained by the S atom which becomes a -2 ion. The ionic compound formed is K2S.