Ejemplo n.º 1
0
import math
from EvEuler import irange
factorials = []

for i in range(0,10):
   factorials.append(math.factorial(i))

max_factor = 0

max_digits = 1

while len(str(max_digits*math.factorial(9)))>max_digits:
   max_digits+=1


max_factor = math.factorial(9)*max_digits

for f in irange(max_factor):
   value = 0
   for d in str(f):
      value += factorials[int(d)]
   if value == f:
      print f
Ejemplo n.º 2
0
def IsPandigital(numstring):
   for i in irange(1,9):
      if numstring.count(str(i))!=1:
         return False
   return True
Ejemplo n.º 3
0
from EvEuler import irange

ansnum = []
ansdem = []

for num in irange(10,98):
   for den in irange(num+1,99):
      #throw out the goofy cases
      if num == den:
         continue
      if num % 10 == 0 or den % 10==0:
         continue

      n1,n2 = num / 10, num % 10
      d1,d2 = den / 10, den % 10

      if n1 != n2 and d1 != d2 and (n1 == d2 or n2 == d1):
         if float(n1)/float(d2) == float(num)/float(den) or float(n2)/float(d1) == float(num)/float(den):
            
            
            print "%d/%d"%(num,den)

Ejemplo n.º 4
0
#1*5?3N

#2*2?5N
#2*3?4Y
#2*4?3N
from EvEuler import irange

pds = []
total = 0
def IsPandigital(numstring):
   for i in irange(1,9):
      if numstring.count(str(i))!=1:
         return False
   return True

for a in irange(1,9):
   for b in irange(1234,9876):
      c = a*b
      if len(str(c)) == 4 and IsPandigital(str(a)+str(b)+str(c)):
         pds.append(c)
         print "%d * %d = %d"%(a,b,c)


for a in irange(12,98):
   for b in irange(123,987):
      c = a*b
      if len(str(c))==4 and IsPandigital(str(a)+str(b)+str(c)):
         pds.append(c)
         print "%d * %d = %d"%(a,b,c)
pds = set(pds)
for i in pds: