from math import factorial def enigme1(nbSol): trouveSol = 0 n = 0 while trouveSol < nbSol: if decroissant(n) - croissant(n) == n: print(n) trouveSol += 1 n += 1 def enigme2(nbSol): trouveSol = 0 n = 0 while trouveSol < nbSol: if 3 * droite(n) == n: print(n) trouveSol += 1 n += 1 def enigme3(nbSol): trouveSol = 0 n = 0 while trouveSol < nbSol: if sommefact(n) == n: print(n) trouveSol += 1 n += 1 def enigme4(nbSol): trouveSol = 0 n = 0 while trouveSol < nbSol: if sommecube(n) == n: print(n) trouveSol += 1 n += 1 def enigme5(nbSol): trouveSol = 0 n = 0 while trouveSol < nbSol: if cubesomme(n) == n: print(n) trouveSol += 1 n += 1 def sommefact(n): return sum([factorial(int(v)) for v in str(n)]) def sommecube(n): return sum([int(v)**3 for v in str(n)]) def cubesomme(n): return sum([int(v) for v in str(n)])**3 def droite(n): s = str(n) return int(s[-1:] + s[:-1]) def croissant(n): s = list(str(n)) s.sort() return int(''.join(s)) def decroissant(n): s = list(str(n)) s.sort() s.reverse() return int(''.join(s))