Comparing terms and finding the first term and common difference