diff options
author | Joshua Drake <joshua.drake@ditchwitch.com> | 2023-04-07 08:13:49 -0500 |
---|---|---|
committer | Joshua Drake <joshua.drake@ditchwitch.com> | 2023-04-07 08:13:49 -0500 |
commit | 1161f9a034de06a63538e3a9a0b7717098c744d9 (patch) | |
tree | 55bb842b2daa4f096eb7916a8d3630426fc1c376 /Problem26.py |
Diffstat (limited to 'Problem26.py')
-rw-r--r-- | Problem26.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Problem26.py b/Problem26.py new file mode 100644 index 0000000..8c57161 --- /dev/null +++ b/Problem26.py @@ -0,0 +1,25 @@ +from decimal import * +getcontext().prec = 30 +def repeatingelement(n): + power = reoccuringlength(n) + return int(pow(10,power)/n) +def reoccuringlength(n): + n = str(Decimal(1)/Decimal(n))[2:] + vals = [0] + maxlength,posy, posx = 0,0,0 + for x in range(0,int(len(n)/2)+1): + for y in range(0,x): + if n.count(n[y:x]) > 1 and (x-y) > maxlength: + vals.append(n[y:x]) + maxlength = (x-y) + return maxlength + +maxrecurringcycle,maxval = 0,0 +for x in range(2,1000): + if repeatingelement(x) > maxrecurringcycle: + maxrecurringcycle = repeatingelement(x) + maxval = x +print(maxval) +print(repeatingelement(7)) + +#Answer is 983 |