Usa el operador %= para averiguar el resto al dividir la variable x por 5.