Ordinarily you would first figure out how many miles the car travels on just one gallon of gas. In this case, since you know how many miles it went on 20 gallons and you need to know how far it can go on 25 gallons, and since both gallon counts are evenly divisible by 5, you can shortcut this a bit by just figuring out how far the car can go on five gallons of gas.
So start by dividing 20 by 5 and you get 4. So the 340 miles was driven using 5 gallons of gas… 4 times over. So just calculate 340 / 4 to figure out how many miles on each 5 gallons. Once you know that, you can add that number back onto the original 340 to figure out how many miles it could go on 25 gallons. (This works because the 25 gallons is just 5 gallons more than the original 20 gallons and you've figured out how many miles the car will go on five gallons.)