efrei/algebre-non-lineaire/oppose.py

26 lines
432 B
Python
Raw Normal View History

2022-01-25 10:25:20 +01:00
#!/usr/bin/env python3
"""Calcul de l'opposé d'un ensemble"""
import sys
def main():
if len(sys.argv) == 3:
a = int(sys.argv[1])
n = int(sys.argv[2])
else:
a = int(input("a : "))
n = int(input("n : "))
oppose = opposer(a, n)
print(f"L'opposé de {a} dans Z/{n}Z est {oppose}")
def opposer(a: int, n: int) -> int:
return (n - a) % n
if __name__ == "__main__":
main()