Created
June 28, 2010 12:19
-
-
Save sbp/455767 to your computer and use it in GitHub Desktop.
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
common = 74 | |
results = [] | |
# following function from http://bit.ly/ftnW6 | |
def factor(n): | |
if n == 1: return [1] | |
i = 2 | |
limit = n**0.5 | |
while i <= limit: | |
if n % i == 0: | |
ret = factor(n/i) | |
ret.append(i) | |
return ret | |
i += 1 | |
return [n] | |
for i in xrange(500): | |
factors = factor(i) | |
diffs = [(abs(common - f), f) for f in factors] | |
minimum = min(diffs) | |
results.append(common - minimum[1]) | |
print ','.join(str(res) for res in results) | |
results = [] | |
for i in xrange(500): | |
factors = factor(i) | |
diffs = [(abs(common - f), f) for f in factors] | |
minimum = min(diffs) | |
results.append(abs(common - minimum[1])) | |
print ','.join(str(res) for res in results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment