Skip to content

Instantly share code, notes, and snippets.

@jevinskie
Created February 17, 2011 19:55
Show Gist options
  • Save jevinskie/832515 to your computer and use it in GitHub Desktop.
Save jevinskie/832515 to your computer and use it in GitHub Desktop.
#!/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