From 9b2d65bac18e3a633e377dcc211fc4c127c6643f Mon Sep 17 00:00:00 2001
From: Alok Shukla <20066073+shuklalok@users.noreply.github.com>
Date: Mon, 4 May 2020 02:18:16 +0530
Subject: [PATCH] Solution for Euler Problem 26 (#1939)

* Solution for Euler Problem 26

* Update project_euler/problem_26/sol1.py

typo error fix.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

typo error fix

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

ok to remove, this comes from Pycharm automatically when docstring is added.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

ok to remove.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update project_euler/problem_26/sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* now_divide = now_divide * 10 % divide_by_number

Co-authored-by: Christian Clauss <cclauss@me.com>
---
 project_euler/problem_26/__init__.py |  0
 project_euler/problem_26/sol1.py     | 41 ++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 project_euler/problem_26/__init__.py
 create mode 100644 project_euler/problem_26/sol1.py

diff --git a/project_euler/problem_26/__init__.py b/project_euler/problem_26/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/project_euler/problem_26/sol1.py b/project_euler/problem_26/sol1.py
new file mode 100644
index 000000000..7b8c44c9c
--- /dev/null
+++ b/project_euler/problem_26/sol1.py
@@ -0,0 +1,41 @@
+"""
+Euler Problem 26
+https://projecteuler.net/problem=26
+Find the value of d < 1000 for which 1/d contains the longest recurring cycle
+in its decimal fraction part.
+"""
+
+def find_digit(numerator: int, digit: int) -> int:
+    """
+    Considering any range can be provided,
+    because as per the problem, the digit d < 1000
+    >>> find_digit(1, 10)
+    7
+    >>> find_digit(10, 100)
+    97
+    >>> find_digit(10, 1000)
+    983
+    """
+    the_digit = 1
+    longest_list_length = 0
+
+    for divide_by_number in range(numerator, digit + 1):
+        has_been_divided = []
+        now_divide = numerator
+        for division_cycle 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
+
+
+# Tests
+if __name__ == "__main__":
+    import doctest
+
+    doctest.testmod()