Ejemplo n.º 1
0
from eulertools import is_pandigital

products = []
for i in range(1, 999):
	for x in range(i, 9999):
		bigstr = str(i) + str(x) + str(x * i)
		if len(bigstr) == 9:
			if is_pandigital(int(bigstr)):
				products.append(x * i)			
				print i, x, x*i, sum(set(products))
print set(products)
print sum(set(products))
	
Ejemplo n.º 2
0
from primes import isprime
from eulertools import is_pandigital

import time
start = time.time()
record = 0
for number in xrange(1, 7654322):
	if is_pandigital(number):
		if isprime(number):
			record = number
print record, time.time() - start
Ejemplo n.º 3
0
from eulertools import is_pandigital

products = []
for i in range(1, 999):
    for x in range(i, 9999):
        bigstr = str(i) + str(x) + str(x * i)
        if len(bigstr) == 9:
            if is_pandigital(int(bigstr)):
                products.append(x * i)
                print i, x, x * i, sum(set(products))
print set(products)
print sum(set(products))
Ejemplo n.º 4
0
#_______Description_____

#https://projecteuler.net/problem=41
#We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
#What is the largest n-digit pandigital prime that exists?
##_______end_description_____:

#only 4 and 7 digit pandigital numbers can be prime because otherwise sum of all digit is divisble by 3 meaning whole number
#is divisible by 3. That's why limit is largest pandigital 7-digit number.

from eulertools import is_prime, is_pandigital

for n in range(7654321, 1, -2):  # looping down, decrementing by 2
    if is_pandigital(n):
        if is_prime(n):
            print(n)
            break
Ejemplo n.º 5
0
#!/usr/bin/python

# Euler Project Problem 104

"""Benchmark
Intel Core2 Duo CPU P8400  @ 2.26GHz 
real	0m0.524s
user	0m0.432s
sys	0m0.024s
"""
from eulertools import is_pandigital
 
def first_digits(n):
    t = n * 0.20898764024997873 - 0.34948500216800943
    return int((pow(10, t-int(t) + 8)))

a = 1
b = 1
n = 1
print first_digits(500)
while not is_pandigital(a) or not is_pandigital(first_digits(n)):
    a, b = b, (a + b)%10**9
    n += 1

print 'Answer to problem 104:', n