Space Fuel Calculation
MATH

Problem

Given an integer distance, representing the distance of the space journey in units, return an integer representing the total amount of fuel needed for the journey.

The total fuel is calculated as five times the distance plus a minimum reserve of 50 units.

Examples

calculateFuel(10) // 100 /* Total fuel is 5 times the distance (10 * 5 = 50) plus the minimum 50 fuel reserve, totaling 100. */ calculateFuel(7) // 85 /* Total fuel is 5 times the distance (7 * 5 = 35) plus the minimum 50 fuel reserve, totaling 85. */ calculateFuel(0) // 50 /* Minimum fuel reserve is 50, regardless of the distance being 0. */
Loading...