Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
package main
import (
"fmt"
"math/big"
"math/rand"
)
func main() {
tx := "00000000000000000002bf59c3d819e4666909512803cf28113ff09849b4545e"
total := int64(10) // type in maxmium lottery nubmer here
fmt.Printf("lucy lottery id: %d\n", Rand(tx, total))
}
// @param tx:
// from site: https://btc.com/block
// The hash of the first block generated after UTC 08:00AM. On 2018-10-11, for example tx is 00000000000000000011f41d5df213f232c1778730e834635eb836276fc184bf
// which from block: https://btc.com/00000000000000000011f41d5df213f232c1778730e834635eb836276fc184bf
// @param total
// the total luck lottery numbers generated duratation the non-mining minutes
//
func Rand(tx string, total int64) int64 {
v, _ := big.NewInt(0).SetString(tx, 16)
seed := v.Int64() // ignore overflow
source := rand.NewSource(seed)
r := rand.New(source)
return r.Int63n(int64(total)) + 1 // +1 because our lottery numbers starts from 1
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more