26 lines
432 B
Python
26 lines
432 B
Python
|
#!/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()
|