I am working with randomly generated strings and the minimum fractional period of those string. The minimum fractional period of a string $s$ can be found by checking the eqaulity between the suffix and prefix of the string starting with those that have length $|s|-1$ up to 1. The algorithm works in this way:
for i from n-1 down to 1 {
if s[1..i] == s[n-i+1..n] {
return n-i;
}
}
return n
If the input strings are generated by randomly choosing a character in the alphabet $ \{'a', 'b'\} $ what is the probability that a string of length $n$ has a minimum fractional period $i$?