Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Форматирование вывода
- function addSpace($data, $spaceLength, $append = false) {
- $dataLength = strlen((string)$data);
- if ($dataLength < $spaceLength) {
- for ($i=0; $i < $spaceLength-$dataLength; $i++) {
- if($append)
- $data .= ' ';
- else
- $data = ' '.$data;
- }
- }
- return ($data);
- }
- // Вычисляем первую ставку
- function calcBet($deposit, $profitFactor, $lossIndex) {
- $factorSum = 1;
- for ($i = 1; $i < $lossIndex; $i++) {
- $factorSum += pow( (1 + (100 / (($profitFactor * 100) - 100))) , $i);
- }
- return round($deposit/$factorSum);
- }
- $deposit = 5000;
- $profitFactor = 1.6;
- $lossIndex = 5;
- $calcBet = calcBet($deposit, $profitFactor, $lossIndex);
- $summaryCredit = 0;
- $betList = array();
- for($round = 1; $round <= $lossIndex; $round++) {
- $bet = $calcBet + round(($summaryCredit * 100) / (($profitFactor * 100) - 100));
- $summaryCredit += $bet;
- $profit = round($bet * $profitFactor);
- $betList[] = array(
- 'bet' => $bet,
- 'credit' => $bet - ($bet*2),
- 'summaryCredit' => $summaryCredit - ($summaryCredit*2),
- 'profit' => $profit,
- 'summaryProfit' => $profit - $summaryCredit,
- );
- }
- echo 'Deposit: '.$deposit.PHP_EOL;
- echo 'Profit Factor: '.$profitFactor.' (+'.(($profitFactor * 100) - 100).'%)'.PHP_EOL;
- echo 'Loss Index: '.$lossIndex.PHP_EOL.PHP_EOL;
- echo 'N |Bet |Credit |SumCredit |Profit |SumProfit |Deposit (Loss)';
- echo PHP_EOL;
- $i=0;
- foreach ($betList as $bet) {
- $i++;
- echo addSpace($i, 3).'|';
- echo addSpace($bet['bet'], 8).'|';
- echo addSpace($bet['credit'], 8).'|';
- echo addSpace($bet['summaryCredit'], 10).'|';
- echo addSpace($bet['profit'], 8).'|';
- echo addSpace($bet['summaryProfit'], 10).'|';
- echo addSpace($deposit - ($bet['summaryCredit'] - ($bet['summaryCredit']*2)), 14).'|';
- echo PHP_EOL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement