While performing a factory reset you are given the option of choosing how to reinstall your Windows. You can either use a local installation media (like a bootable USB drive) or download the files from the cloud. The cloud option is better as it installs the latest version of Windows with no chance of any corrupted files.