The stud formula is studs = round up (wall length in inches divided by spacing in inches) + 1. Each part means one thing, and the plus one is the part people forget.
Wall length in inches is the wall in feet multiplied by 12, so a 20 ft wall is 240 in. Spacing is the on-center distance, measured from the center of one stud to the center of the next, not the clear gap between them. Divide 240 by 16 and you get 15 bays, and the +1 adds the stud at the far end, so the run needs 16 field studs.
Then add the extras. Each corner needs 3 studs for the corner assembly and drywall backing, and each door or window opening needs 4 studs, 2 king studs that run full height on each side and 2 jack studs that carry the header. Finally, multiply the subtotal by 1 plus the waste percentage and round up, because you cannot buy part of a stud. Our framing calculator covers the wider framing takeoff, including headers and sheathing.