a basic method

A basic method with an efficiency of O(n).