买彩票保证不赔本的最小花费
2019/03/10
买彩票保证每次买彩票后如果中奖则不赔本的最小花费
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> </body> <script type="text/javascript"> var countCurrPay = function(n){ var orderCurr = n;//n本次是第几次购买 var SumBefore = 0;//之前总花费 var payCurr = 0;//本次需要花费金额 for (var i = 1; i < orderCurr; i++) { var sumCurr = SumBefore*2/3; if(sumCurr==0){ sumCurr = 2; } if(Math.ceil(sumCurr)%2==1){ sumCurr = Math.ceil(sumCurr)+1; }else{ sumCurr = Math.ceil(sumCurr); } SumBefore = SumBefore + sumCurr; } payCurr = Math.ceil(SumBefore*2/3) if(payCurr==0){ payCurr = 2; } if(Math.ceil(payCurr)%2==1){ payCurr = Math.ceil(payCurr)+1; }else{ payCurr = Math.ceil(payCurr); } return {SumBefore:SumBefore,payCurr:payCurr,allPay:SumBefore+payCurr}; } console.log(countCurrPay(15)) </script> </html>
每注两元,中奖的话19.4,保本不赔的卖法
var countCurrPay = function (n) { var orderCurr = n; //n本次是第几次购买 var SumBefore = 0; //之前总花费 var payCurr = 0; //本次需要花费金额 for (var i = 1; i < orderCurr; i++) { var sumCurr = SumBefore * 2 / 17.4; if (sumCurr == 0) { sumCurr = 2; } if (Math.ceil(sumCurr) % 2 == 1) { sumCurr = Math.ceil(sumCurr) + 1; } else { sumCurr = Math.ceil(sumCurr); } SumBefore = SumBefore + sumCurr; } payCurr = Math.ceil(SumBefore * 2 / 17.4) if (payCurr == 0) { payCurr = 2; } if (Math.ceil(payCurr) % 2 == 1) { payCurr = Math.ceil(payCurr) + 1; } else { payCurr = Math.ceil(payCurr); } return { SumBefore: SumBefore, payCurr: payCurr, allPay: SumBefore + payCurr }; } console.log(countCurrPay(15))
上一篇:
chrome设置跨域问题
下一篇:
vsCode 添加文件夹右键菜单
静水缘首页
刘丕水+宋静静于2007年9月相识于山东理 工大学,毕业后2011年相恋,共甘苦,历 时四年,终于在11月23号拿到了红本本, 组建了自己的小家庭......文章分类
最新文章
- nodejs私钥加密公钥解密的一个例子
- uniapp和微信小程序判断程序运行在开发或者测试或者线上版本的方法分别是什么
- electron使用electron-builder打包后模块包含exe文件执行失败
- Compile is disallowed on the main thread, if the buffer size is larger than 4KB
- better-sqlite3简介及常用操作
- nodejs 操作数据库的库
- nodejs使用http-proxy库实现多个域名代理和同时代理websocket的例子,代理包含https和http两种协议
- iis配置反向代理
- javascript伪多线程代码
- ip所在地址段判断