Calculate period length of recurring decimal fraction
问题 I want to do a program in python (3.6.5) that tell the length of e.g. 1/7. The output should be for this example something like: "length: 6, repeated numbers: 142857". I got this so far: n = int(input("numerator: ")) d = int(input("denominator: ")) def t(n, d): x = n * 9 z = x k = 1 while z % d: z = z * 10 + x k += 1 print ("length:", k) print ("repeated numbers:", t) return k, z / d t(n, d) 回答1: Doing print ("repeated numbers:", t) prints the representation of the t function itself, not its