4th and 5th digits of your serial number. FWIW te 1st and 2nd are the factory number and the 3rd is the year.
Week 33 bought at Apple Store in Phoenix on Aug 17 - 4.0.2
Well, there we have it. 4.0.2 started coming pre-installed sometime between the start of Week 32 and the end of Week 33.
I got a shipment of 3Gs' today and they were on 4.0.1. I'll post back when i get my 4's in tomorrow with what they are on...