HackerRank Time Complexity: Primality Interview preparation kit solution