Methane is 1C4H. All alkanes are evolved from methane.
The definition of alkane is that every carbon-carbon bond in the molecule is a single bond (saturated).
So what do you find when the substituent replaces methane (-CH3 replaces -H)? One more C, two more H, pay attention to two! That's very simple. When alkyl is substituted, it is equivalent to adding methylene (-CH2-) one at a time. Let C(B) represent the number of carbon in b and H(B) represent the number of hydrogen in b, then
C(CH4)= 1,H(CH4)=4,H(CH4)=2*C(CH4)+2
Adding one more methylene at a time is equivalent to 2*C(CH4). Add C (CH2) = 1 and H (CH2) = 2 here, and that "+2" will never change! Therefore, the general formula of alkanes is C2nH2n+2.
There is also a deductive method. Alkanes can be regarded as a string (H-CH2-CH2-CH2-H), and each isomer is just the transposition of H and a certain CH3 in the molecule. This is easy to understand: every alkane has CH2 in the middle and two H at the end. So the problem is very clear, and the general formula is C2nH2n+2.