Last active
August 21, 2018 11:53
-
-
Save williankeller/779a20dd0c8f1c571a0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public static function getAcrescimo($valor, $parcelas, $acrescimo) | |
| { | |
| if (!is_numeric($valor) || $valor <= 0) { | |
| return false; | |
| } | |
| if ((int) $parcelas != $parcelas) { | |
| return false; | |
| } | |
| if (!is_numeric($acrescimo) || $acrescimo < 0) { | |
| return false; | |
| } | |
| $denominador = 0; | |
| if ($parcelas > 1) { | |
| for ($i = 1; $i <= $parcelas; $i++) { | |
| $denominador += (1 / pow(1 + ($acrescimo / 100), $i)); | |
| } | |
| } else { | |
| $denominador = 1; | |
| } | |
| return ($valor / $denominador); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment