I know it's been years, but I can't help myself. @penguino's answer is good, but ignores some important aspects of the scenario.
Unless one wishes to arrive on the surface of Mars at 60,000mph (ouch!), you need to account for deceleration. You won't have a railgun to do it for you, so you'll need rocket engines and fuel tanks onboard your projectile, with the ability to orient the craft in space so that you can use the rockets to decelerate.
At launch time, rendering the occupants unconscious by making them sustain 15G for a few minutes is borderline acceptable, as they'll have a couple weeks to recover during the flight and very little else to worry about during that time. However, when it comes time to land, I think it's ideal if a pilot can remain conscious and able to control the ship's systems during descent, so maybe we want to limit ourselves to something more like 1-44G. Doing the math, decelerating to zero at 4G would take eleven minutes; 22 minutes at 2G, 45 minutes at 1G. So, none of these have a significant impact on travel time. I'd be tempted to pick 1G just to minimize the chance of issues and maximize opportunities to make corrections. You'll get there the same day regardless.
Now we get to the fun part. Using a rocket to create a ΔV of 27,000m/s, imagining that the projectile itself (with rocket engines and fuel tanks but no rocket fuel) weighs 100 metric tons (a Saturn V rocket weighs 130t empty), and optimistically selecting an extremely efficient rocket fuel (liquid hydrogen-oxygen, netting an exhaust velocity of ~4.5km/s), we plug our numbers into the Tsiolkovsky Rocket Equation and find that we need a bit over 40,000 tons of rocket fuel onboard at launch in order to perform that acceleration. For comparison, the aforementioned Saturn V carried ~2800t across three stages, which was sufficient to reach the moon, performing most of the transit at a relatively paltry ~2.5km/s.
Now, we go back to that rail launcher. It needs to accelerate 40,000 tons and change to 27km/sec over 2400km. Assuming linear acceleration, that means we need to perform the acceleration over the course of roughly three minutes.
This task will require the linear accelerator to deliver 14,580,000,000,000,000 joules (14.58 petajoules) of kinetic energy into the vehicle. The best railguns are about 66% efficient, so the power source needs to supply a total of 22.1PJ. To do so in the three-minute timeframe will require a continuous supply of 123 terawatts of electrical power -- enough to illuminate more than two trillion 60W light bulbs. The combined electrical generation power of the entire United States is approximately one terawatt; the entire world can generate about 7.7TW at theoretical peak capacity (which is never attained).
So, before you can operate your rail gun, you're going to need to install some serious power generation and delivery equipment on the moon. I'm envisioning nuclear power plants (because most power generation technologies we know today wouldn't work on the moon, although I'd be interested to work out what you could accomplish with solar) and millions of supercapacitors spread out along the railgun to deliver the energy.
But wait, I'm not done! Recall that our launch rail is two-thirds the Moon's diameter and needs to be straight. We'll need to bore a hole through the moon. I'll spare you the math, but if we drill a chord through the moon from surface to surface of the appropriate length, we luckily avoid the molten iron outer core, and we gain some serviceability and safety by having two entrances! Maximum distance of this tunnel from the nearest surface point is about 462km, and, as stated before, the total length of the tunnel is 2400km. The deepest borehole we've ever created on Earth is about 12km deep and only 12" wide. As the hole gets wider, more depth gets more difficult, and I hope I don't need to remind you that our 40 kiloton vehicle will be a bit wider than 12". Needless to say, we will need to make significant strides in our boring technology before this becomes feasible! Maybe Elon Musk can help.
As a bonus to this through-the-moon approach, however, is that we get a light assist from the Moon's gravity during the first half of the acceleration phase. It's completely offset by the second half as we move farther from the center of the moon, but it's better than fighting gravity the entire time, as is typical of most launch systems.
Factors still not considered:
- How to get the launch vehicle, its fuel, the railgun, the power generation equipment, and all supporting infrastructure to the moon
- How to build a 2400km-long railgun
- Additional energy required to escape the Moon's and Earth's gravity wells
- Since we're boring a hole through the moon, we can only use it at one specific moment, when it's aimed straight at Mars. Otherwise, we're wasting a significant portion of our launch energy and need to pack even more rocket fuel in order to adjust course. I'm not sure how often the hole would be in alignment and not obstructed by Earth, nor how wide the launch windows would be.
- Note that both Earth and Mars are moving quite fast (relative to the Sun). As such, you can't just make a straight-line path from one to the other. Instead, you need to plan a Transfer orbit, which takes a much longer path -- usually roughly 2x the direct line.
Between the borehole, the launch power requirements, the vehicle size, and the logistics, I think that we can conclude two things:
1. We as a species are nowhere close to being ready to implement this.
2. Maybe just go a bit slower.
Note: I used Saturn V for reference because it's the heaviest-lift-capable launch vehicle I'm aware of that was actually put into use and therefore has significant data available about it. Ares V was, and SLS is, slated to be more capable, and I'm guessing somewhat more efficient, but detailed figures are not readily available.
Finally, just to address a couple misconceptions in the question and its comments:
- The speed of sound on Earth and in space have nothing to do with this. On Earth, the speed of sound is relevant because you have to deal with shockwaves when you exceed it. The moon's lack of an atmosphere renders this moot.
- From comments: "if there is no resistance against the moving object, how do you determine the speed it can achieve?" When there is no resistance, there is no speed limit -- you are only limited by your ability to apply force in the correct direction to accelerate. However, there is in fact some resistance -- the vehicle will be in the Sun's gravity well the entire time. It's a relatively small force, but it will cause the coasting vehicle to decelerate slightly beginning the moment the railgun stops accelerating the vehicle.