euler problem 26 https projecteuler netproblem26 problem statement a unit fraction contains 1 in the numerator the decimal representation of the unit fractions with denominators 2 to 10 are given 12 0 5 13 0 3 14 0 25 15 0 2 16 0 16 17 0 142857 18 0 125 19 0 1 110 0 1 where 0 16 means 0 166666 and has a 1digit recurring cycle it can be seen that 17 has a 6digit recurring cycle find the value of d 1000 for which 1d contains the longest recurring cycle in its decimal fraction part considering any range can be provided because as per the problem the digit d 1000 solution1 10 7 solution10 100 97 solution10 1000 983 tests considering any range can be provided because as per the problem the digit d 1000 solution 1 10 7 solution 10 100 97 solution 10 1000 983 tests
def solution(numerator: int = 1, digit: int = 1000) -> int:
    
    the_digit = 1
    longest_list_length = 0

    for divide_by_number in range(numerator, digit + 1):
        has_been_divided: list[int] = []
        now_divide = numerator
        for _ in range(1, digit + 1):
            if now_divide in has_been_divided:
                if longest_list_length < len(has_been_divided):
                    longest_list_length = len(has_been_divided)
                    the_digit = divide_by_number
            else:
                has_been_divided.append(now_divide)
                now_divide = now_divide * 10 % divide_by_number

    return the_digit



if __name__ == "__main__":
    import doctest

    doctest.testmod()