Patterns and the Josephus Problem