Skip to content

Instantly share code, notes, and snippets.

@anivarth
Created May 25, 2016 16:00
Project Euler Problem 38 Solution With Python
# http://radiusofcircle.blogspot.com
# import time module for calculating execution time
import time
# time at the start of program execution
start = time.time()
# largest pandigital number
largest = 0
# for loop to loop till 4 digits
for i in xrange(1,10000):
# value for concatenated product
multiplication = ''
# (1,2,3,4,.....n)
integer = 1
# if the multiplication < 9 digits
while len(multiplication) < 9:
# concatenating the product at each stage
multiplication += str(i*integer)
# incrementing (1,2,3,4,....n)
integer += 1
# check for digits less than 9
# check for all 1-9 numbers
# check if '0' not in concatenated sting
if ((len(multiplication) == 9) and (len(set(multiplication)) == 9)
and ('0' not in multiplication)):
# check if multiplication is greater than largest
if int(multiplication) > largest:
largest = int(multiplication)
# printing the largest
print largest
# time at the end of program execution
end = time.time()
#total time for execution
print end - start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment