Originally the Army Air Corps and later the Army Air Force, had completely different designations from the Navy. The Navy used a setup with letters standing for the function of the aircraft followed by the number of aircraft of that type it was from that company, and then a letter that stood for the company that produced the plane. For example:
F-4f = Fighter, 4th model from Grumman, f=Grumman
F-4U-1 Fighter, 4th model from Chance Vought, U=Chance Vought, 1st variant of this aircraft
TBF = Torpedo Bomber, made by Grumman
The Army Air Corps simply numbered their planes starting at 1, no matter who the manufacturer was, and prefaced the designation with a letter standing for the function or aircraft type, then a letter for the mark, or variation within the model:
P-51b = Pursuit, 51st type, 2d model of
B-17f = Bomber, 17th, 5th model of
Later the newly created Air Force changed all P designations to F thus the P-51 Mustang became the F-51 Mustang for the Korean War, and in one of the more confusing shifts, they started calling A-26 the B-26 (not to be confused with the WW2 B-26 which we have in AH).
Then, somewhere around the Vietnam war, the Army, Navy, and USMC decided to standardize designations between the services, resetting the number count to 1. Since then, no matter what the branch the numbers have gone up from there. The missing numbers like F-17 are actually prototypes that didnt see production due to losing in competition with another type. The F-17 was a competitor to the F-16 for the AF lightweight fighter contract which it lost. Later of course it became the F-18 for the USN and USMC.
The current alphabet soup as it stands now is as follows:
A= attack
B= bomber
C= cargo
E= electronic warfare
F= fighter
H= helicoptor
K= tanker
L=liaison, also used for special Antarctic types
M= special operations
O= observation
P= patrol
Q= drone
R= reconnaissance
S= spyplane, also antisubmarine
T= trainer
U= utility
V= VIP transport, formerly used to designate a spotter or liaison
W= weather tracking
X= experimental
Y= prototype
There are always exceptions to this, for example, the F-117 was just randomly numbered at 117 and was designated a fighter as something of a deception. The old fighter numbers had stopped at 111 before they reset them to standardize between the services.