def main(limit): count = 2 fibs = [0, 1] while count < limit: val = sum(fibs) % (10**9) fibs[0] = fibs[1] fibs[1] = val val_str = str(val) if is_pandigital(val_str): if is_pandigital(str(top9_digits(count))): print count count += 1
#!/usr/bin/env python import time from Euler import is_pandigital t_0 = time.clock() for i in xrange(9876,1,-1): n = i*100000 + i*2 if is_pandigital(n): print n break print time.clock() - t_0, 'seconds to complete'
#!/usr/bin/python -Wall # -*- coding: utf-8 -*- """ <div id="content"> <div style="text-align:center;" class="print"><img src="images/print_page_logo.png" alt="projecteuler.net" style="border:none;" /></div> <h2>Pandigital multiples</h2><div id="problem_info" class="info"><h3>Problem 38</h3><span>Published on Friday, 28th February 2003, 06:00 pm; Solved by 37585; Difficulty rating: 5%</span></div> <div class="problem_content" role="problem"> <p>Take the number 192 and multiply it by each of 1, 2, and 3:</p> <blockquote>192 × 1 = 192<br /> 192 × 2 = 384<br /> 192 × 3 = 576</blockquote> <p>By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)</p> <p>The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).</p> <p>What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , <var>n</var>) where <var>n</var> > 1?</p> </div><br /> <br /></div> """ from Euler import is_pandigital for i in range(9999, 9000, -1): a1 = i * 1 a2 = i * 2 buf ="%d%d" % (a1, a2) if (is_pandigital(int(buf))): print buf
from Euler import is_pandigital def top_digits(n): # Gets last 9 digits. t = n * 0.20898764024997873 + (-0.3494850021680094) t = int((pow(10, t - int(t) + 8))) return t fk, f0, f1 = 2, 1, 1 while not is_pandigital(f1) or not is_pandigital(top_digits(fk)): f0, f1 = f1, (f1 + f0) % 10**9 fk += 1 print fk
#!/usr/bin/python -Wall # -*- coding: utf-8 -*- """ <div id="content"> <div style="text-align:center;" class="print"><img src="images/print_page_logo.png" alt="projecteuler.net" style="border:none;" /></div> <h2>Pandigital multiples</h2><div id="problem_info" class="info"><h3>Problem 38</h3><span>Published on Friday, 28th February 2003, 06:00 pm; Solved by 37585; Difficulty rating: 5%</span></div> <div class="problem_content" role="problem"> <p>Take the number 192 and multiply it by each of 1, 2, and 3:</p> <blockquote>192 × 1 = 192<br /> 192 × 2 = 384<br /> 192 × 3 = 576</blockquote> <p>By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)</p> <p>The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).</p> <p>What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , <var>n</var>) where <var>n</var> > 1?</p> </div><br /> <br /></div> """ from Euler import is_pandigital for i in range(9999, 9000, -1): a1 = i * 1 a2 = i * 2 buf = "%d%d" % (a1, a2) if (is_pandigital(int(buf))): print buf
from Euler import is_pandigital p = set() for i in range(2,100): start = 1234 if i>9: start = 123 for j in range(start, 10000/i+1): if is_pandigital(str(i)+str(j)+str(i*j)): p.add(i*j) print "Answer to PE32 = ",sum(p)
#!/usr/bin/env python import time from Euler import is_pandigital t_0 = time.clock() for i in xrange(9876, 1, -1): n = i * 100000 + i * 2 if is_pandigital(n): print n break print time.clock() - t_0, 'seconds to complete'