Prime numbers algorithm