Created
February 17, 2011 19:55
-
-
Save jevinskie/832515 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
def count_ones(n): | |
res = 0 | |
while n > 0: | |
if n % 10 == 1: | |
res += 1 | |
n /= 10 | |
return res | |
def F(n): | |
return sum(map(count_ones, xrange(n+1))) | |
def find_convergence(): | |
i = 2 | |
while i != F(i): | |
if i % 1000 == 0: | |
print "got to %d" % i | |
i += 1 | |
print "found convergence at %d" % i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment