The Mathematics of Gambling