Toptal Interview Question

String processing and prime numbers