I am thinking of using prime numbers as a way to search (and scan) through a text. In regular string matching, the algorithm will compare each character of string to be compared sequentially.
My idea was to skip the i-th character by a value of a prime number.
For example, if nth character doesn’t match, see if it matches after skipping 7 characters (a prime number) more in the string.
I am thinking of storing few prime numbers in an array then using it as a variable to skip the characters during the scan.
For example, if skipping 7 characters is too much, reduce to 3 characters or the opposite, increase to skipping 17 characters.
I would like this algorithm made in C for performance.
I have included a pseudo code and C mix as a sketch for you to see what the algorithm is like.