Skip to content
Advertisement

PHP with Loop Calculation [closed]

Can some help, don’t know how to solve this using loop in PHP

JavaScript

I want the loop to achieve this result

JavaScript

My code is:

JavaScript

My code is giving me this result:

JavaScript

Advertisement

Answer

The code below, loops through the $pays array of integers.

each loop calculates the equation of $captial minus one of the integers and repeats, this is calculated and stored as a string in the $lines variable and at the end of each loop we recalculate the $capital and update the new value of $capital based on the previous calculation of capital = capital - pay

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement