This alogorithm finds the last number that meets our criteria within the specified range (12-digit numbers)