Logo Les Interros des Lycées
anagramme2.py
Programme Python de l'Interros des Lycées
from math import factorial

mot = input("Entrez un mot : ")

n = len(mot)
L = []
P = 1

for lettre in mot:
    c = ( lettre , mot.count(lettre) )
    if c not in L:
        L.append(c)
        P *= factorial(c[1])
   
N = int(factorial(n) / P)

print("Le nombre d'anagrammes de",mot," est égal à",N, end=".")