From ddc4943f576a354118f56ee18b374463f89e4ff2 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 12 Oct 2020 20:39:14 +0200 Subject: [PATCH] Solve task --- src/task26 - Reciprocal cycles.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/task26 - Reciprocal cycles.py b/src/task26 - Reciprocal cycles.py index a8b3bf0..f899bb8 100644 --- a/src/task26 - Reciprocal cycles.py +++ b/src/task26 - Reciprocal cycles.py @@ -1,4 +1,16 @@ -for i in range(1,1000): - x = 1/i - \ No newline at end of file + +numsWithRecurringCycles = [n for n in range(2,1000) if n % 2 != 0 and n % 5 != 0] + +def digits(num, divisor): + x = num + storedSums = [] + while not x*10 in storedSums: + x *= 10 + storedSums.append(x) + x %= divisor + return len(storedSums) + +digitNumList = [digits(1, n) for n in numsWithRecurringCycles] + +print(numsWithRecurringCycles[digitNumList.index(max(digitNumList))])