Thanks for the question, and welcome to Apple Support Communities.
You are correct, if you have forgotten your passcode you'll need to restore the device back to factory settings. The following article outlines how to do so:
Please note: restoring your device will erase all contents, and any media or personal files that were not backed up will be lost.
If you have never synced your device with iTunes:
Connecting the device may result in this error message: "iTunes could not connect to the [device] because it is locked with a passcode. You must enter your passcode on the [device] before it can be used with iTunes."
1. Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
2. Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.
3. While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
4. Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears, release the Home button.
5. iTunes should alert you that it has detected a device in recovery mode. Click OK, and then click Restore to restore the device.