Sweden's prime minister has resigned.