modular arithmetic python - Search