I'm not sure if you are referencing the PIN code to unlock or if you want the recovery key to reset the device if it had device protection enabled.
If it is the PIN code to unlock the device and if you forgot it the only choice is to Hard Reset. If you DO have reset protection enabled then get the recovery key first by doing what is indicated below. After you get the key then hard reset
Here's what you can do to get the Recovery Key:
- Go to account.microsoft.com/devices.
- Next to the phone you no longer own, look for "Get Recovery Key"
- Click on "Get Recovery Key"
- Select the "I'm ready to get a recovery key.
Now you can hard reset your device. (look here: http://resetwindowsphone.com/tag/nokia-lumia-1520/)
- It is a good idea to charge your phone to at least 50%
- Turn off your phone
- Hold down the Volume Down button during 3 seconds, and then hold down and release the Power button, while still pressing the Volume Down button.
- Let go of the Volume Down button and go through the following sequence: VOLUME UP -> VOLUME DOWN – POWER – VOLUME DOWN.
- Windows Phone will now start the process to return your phone to factory settings. This process will take about 5 minutes. After the process is finished, the Nokia Lumia 1520 will re-start, and the device will be in the same state it was when it came out of the box.