The website I prefer for UK train timetables is traintimes.org.uk. One of it's handy features is being able to look up the last train of the day, for example the last train on a Tuesday from Gatwick to Cambridge.
As Roflcoptr pointed out, the last weekday train at the moment is the 22:35, which gets you into Cambridge at 01:22 (via a cross London transfer to Kings Cross). You might just be able to get away with the 22:50 from Gatwick, if you haven't got too much luggage. The 22:50 gets into London Victoria at 23:20, which gives you 40 minutes to get down to the tube, wait for a tube, travel 5 stops, and get up to the station. Fine if there are no problems and you're not too bad for luggage, but can't be guaranteed...
Otherwise, it's a National Express coach to London, then change onto a different National Express coach to Cambridge. The website for looking up times and prices is this one. Doesn't look good though, leaving Gatwick at 23:40 today won't get you to Cambridge until about 5am...