Calculate Fuel for Advanced Spaceship
MATH

Problem

Given an integer distance, representing the distance to be traveled, calculate the total fuel needed for an advanced spaceship. The fuel calculation is based on these rules:

  1. For the first 100 units of distance, the spaceship requires 3 times the fuel.
  2. For the next 200 units (from 101 to 300), it requires 5 times the fuel.
  3. For any distance beyond 300 units, it requires 7 times the fuel.
  4. There is always a minimum fuel reserve of 50 units required, regardless of the distance.

Examples

advancedSpaceshipFuel(10) // 80 advancedSpaceshipFuel(110) // 560 advancedSpaceshipFuel(350) // 2050
Loading...