Skip to content

Instantly share code, notes, and snippets.

@deyvin
Created November 28, 2013 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deyvin/7696412 to your computer and use it in GitHub Desktop.
Save deyvin/7696412 to your computer and use it in GitHub Desktop.
<?php
define('TOTALAPLICADO', 1000);
define('PERC_RENDIMENTO', 15);
define('DIAS', 31);
$total_por_dia = ((TOTALAPLICADO * PERC_RENDIMENTO) / 100) / DIAS;
$percentuais = $percentual = $dias = array();
for($i=0; $i<DIAS; $i++) {
$percentual = rand(0, 100);
$percentual += ( (100 * count($percentuais)) - array_sum($percentuais));
$rendimentos[] = array('dia' => $i, 'rendimento' => ($total_por_dia * $percentual) / 100, 'percentual' => $percentual);
$percentuais[] = $percentual;
}
$percentual = ( (100 * count($percentuais)) - array_sum($percentuais));
$rendimentos[] = array('dia' => 'bonus', 'rendimento' => ($total_por_dia * $percentual) / 100, 'percentual' => $percentual);
print_r($rendimentos);
$total = 0;
foreach($rendimentos as $e) {
$total += $e['rendimento'];
}
echo $total;
echo "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment