Can i use my sim in an iphone 3gs?

So my friend said he will sell me his old iphone 3gs on O2. My sim card i O2 Pay as you go, his was contract. So if i restore the iphone and put my sim in will it still work? Also does i run IOS 1.6.3?

Yes, it will still work as it is running on the O2 network and it does run IOS 1.6.3 but he may not have that OS installed yet so you may need to update it yourself, which you can do in settings.