/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/python # Project Euler - Problem 13 print "\nProject Euler - Problem 13" print "Find the first ten digits of the sum" print "of a set of one-hundred 50-digit numbers." # Read in first 50-digit number f = open('problem13.num', 'r') x = [None]*50 p = [None]*100 sum = 0 for n in range(0,100): for i in range(0,50): x[i] = (f.read(1)) if (x[i] == '\n'): x[i] = f.read(1) s = ''.join(map(str, x)) sum += int(s) print sum
Comments
