The number of substrings (of all lengths inclusive) that can be formed from a character string of length $n$ is
This might help:
https://math.stackexchange.com/questions/1237097/difference-subsequences-and-substrings
https://gateoverflow.in/87874/gate1989-4-i
Gatecse
I'll write a post on how to best...