Author

Topic: Calculate total coins at height (Read 1124 times)

hero member
Activity: 714
Merit: 500
April 05, 2011, 03:41:12 PM
#3
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...  Lips sealed
sr. member
Activity: 322
Merit: 250
April 05, 2011, 02:47:20 PM
#2
sr. member
Activity: 337
Merit: 285
April 05, 2011, 02:41:50 PM
#1
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
Jump to: