There is a simple crisscross method for the same ->
Element-Potassium(K)Sulfate(SO4)
Valency - +1 _______ -2
Now, write the valencies of a elements in the subscript of other..Means write the valency of sulfate in subscript of Pottasium and valency of Potassium in subscript of Sulfate. Like this - K₂SO4..Similarly Magnesium sulfate is MgSO4