implemented first test algoritm for brute force O(n)