Welcome to iMore! Are you referring to the iCloud security code used to unlock the device, or the 2 factor authentication code?
Register in so we can better help you.
Try to retrieve your code here https://iforgot.apple.com.
If that's not what you're looking for or If you have any other questions, please register here to our forum. We're happy to help.