function getCommonDivisor(FirstNum,SecondNum) {
  if (SecondNum == 0) return FirstNum;

  var remainder = parseInt(FirstNum % SecondNum) ;

  return getCommonDivisor(SecondNum, remainder);
}


function getProbability (quantity,coinQuantity) {
  //如果用户克币数是0
  if(quantity == 0) {
    return '0/'+coinQuantity;
  }
  var divisor = getCommonDivisor(quantity,coinQuantity);
  var value = quantity/divisor;
  var value2 = coinQuantity/divisor;
  //如果分子比分母大说明中奖概率是100%，那么返回中奖概率
  if(value>=value2) {
    return coinQuantity+"/"+coinQuantity
  } else {
    return value+"/"+value2
  }
}
module.exports = {
  getProbability:getProbability
};
