I found an at&t iphone 5 but it has a lock on it, how do i factory unlock it?

I turned it on and it asked for a four digit password:/

You don't. You take it to an AT&T store and let them find out who it belongs to. They will notify the owner.

You have to restore it on iTunes to get rid of the code

Do the right thing, turn it in to the police so they can give it to its rightful owner. If you lost your phone you would want it back, wouldn't you?

There are service offered which lets you unlock your iPhone to any network or service provider. Even iPhone 5 can be unlocked. ATTiPhoneUnlock.net provides factory iPhone unlocks for any iPhone model and many networks available worldwide.

Do a full restore in iTunes that will get rid of the passcode lock, but erase all the data