Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: tcatm on April 05, 2011, 07:41:50 PM



Title: Calculate total coins at height
Post by: tcatm on April 05, 2011, 07:41:50 PM
Hey,

here's some code that calculates the total number of bitcoins generated at a certain height:

Code:
def t(h):
    return (sum([21e4*int(50e8/2**k) for k in xrange(int((h+1)/21e4))])+int(50e8/2**(int((h+1)/21e4)))*((h+1)-(int((h+1)/21e4))*21e4))/1e8


Title: Re: Calculate total coins at height
Post by: FatherMcGruder on April 05, 2011, 07:47:20 PM


Title: Re: Calculate total coins at height
Post by: ryepdx on April 05, 2011, 08:41:12 PM
Hey,

here's some code that calculates the total number of bitcoins generated at a certain height:

Code:
def t(h):
    return sum([21e4*int(50e8/2**k) for k in xrange(int((h+1)/21e4))])+int(50e8/2**(int((h+1)/21e4)))*((h+1)-(int((h+1)/21e4))*21e4)/1e8

Very clever...  :-X