I've graded all the submitted midterms and sent out emails with your scores.
Some stats:
* 2/3 of the people who took the exam got a perfect score. Some
were more perfect than others, but I was very generous. In most cases
when people did badly, it was a small issue... though of course a few
people clearly weren't paying attention.
* The three people to compute d(10^8) in under 10 seconds were:
Andrew Richman (5.29 s), Michael Snider (6.88 s), and Sunnye Kim (8.72
s).
Andrew Richman's code is perhaps surprisingly simple and short:
%cython
cpdef cy_digit_divide(int z):
if z <= 0:
raise ValueError("Input must be a positive number")
cdef int y = 0
for i in xrange(1,z):
y += cyDigitDivide(i)
return y
cdef int cyDigitDivide(int n):
cdef int x = n
while x != 0:
if x%10==0 or n%(x%10)!=0:
return 0
x=x/10
return 1
Running it we get:
%time
print cy_digit_divide(10^8)
326499
CPU time: 5.28 s, Wall time: 5.28 s
--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org