The recovery mode method in the following has instructions: If you forgot the passcode for your iPhone, iPad, or iPod touch, or your device is disabled - Apple Support
But be aware that the next thing you are likely to encounter is Activation Lock and there is no way around that without the assistance of the previous owner: Turn off Find My iPhone Activation Lock - Apple Support