1. 程式人生 > >Bitcoins will be stopped issuing in 2140 and 21 million bitcoins in total

Bitcoins will be stopped issuing in 2140 and 21 million bitcoins in total

package main

import (
	"math"
	"fmt"
)

func DecayPeriod() int {
	return int(math.Round(10*210000.0/60/24/365))
}

func DecayTimes() (float64,int) {
	btc:=50.0
	reward:=0.0
	times:=0
	for btc>=math.Pow10(-8) {
		reward+=210000*btc
		btc*=.5
		times++
	}
	return reward,times
}

func main()  {
	period:=DecayPeriod()
	reward,times:=DecayTimes()
	start:=2008
	end:=start+period*times
	fmt.Print(reward,end)
}