The main question is, are you going to sell it including Windows or without a license.
The license code is hard coded to the system itself, when reinstalling Windows you just choose the right flavour (Home or Pro depending on the license) and click the "I don't have a license code" link in the window asking for it. If the version is right it will activate automatically.
The installation media can be downloaded directly from Microsoft:
https://www.microsoft.com/en-us/software-download/windows10 or
https://www.microsoft.com/en-us/software-download/windows11.
You can even clean the system for selling by choosing Start > Settings > Update & Security > Recovery > Reset this PC > Get Started. Choose not to save your data and continue as suggested. You can stop at the point where they start asking about your location, language and keyboard so the new owner can make their own choices.
CAUTION: If you have more than one disk or even partition, they may not get wiped clean so do that before resetting. Tools like CCleaner can be used for sanitizing any disk/area that has been marked empty. That may not be 'secret agent proof' but will prevent accidentally finding your data. If you're worried about your privacy, sell your system without disks. Someone might be interested enough to spend some tenners for a data recovery program that might be able to recover even overwritten data. That said, I have invested into a couple of the better ones and even they can't find all the data from corrupted disks even though they haven't been overwritten. Not to mention the case when I accidentally cloned a brand new empty disk over a failed one: No data to be found.