Maximum sequence number in GBN is same as window size.
For sequence bits = n, number of sequence numbers = 2n and window size = 2n - 1
Consider n = 3, sequence numbers will be 23 = 8 ( i.e. from 0 - 7 )
and maximum window size = 23 - 1 = 7 i.e window will carry frames from 0 to 6 which are 7 in number.
Now, for sender window = 5
number of sequence bits needed = ceil (log2(1+window size)) = 3
So, sequence numbers generated would be 0 to 7 but window will carry frames from 0 to 4 which is 5 in number (same as window size)