Created
June 22, 2016 14:37
Project Euler Problem 57 Solution With Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://radiusofcircle.blogspot.com | |
# time module | |
import time | |
# time at the start of program execution | |
start = time.time() | |
# p | |
p = 1 | |
# q | |
q = 1 | |
# counter | |
counter = 0 | |
# 1000 iterations | |
for i in xrange(1000): | |
a1 = p + 2*q | |
b1 = p + q | |
if len(str(a1)) > len(str(b1)): | |
counter += 1 | |
p = a1 | |
q = b1 | |
# printing the counter | |
print counter | |
# time at the end of program execution | |
end = time.time() | |
# total time of execution | |
print end - start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment