Пример #1
0
def p26(stop: int) -> int:
    # Fact: The period of repeating decimal (1/n) is always < n.

    n_with_max_period = 0
    max_period = 0
    for n in range(stop - 1, 0, -1):
        if n <= max_period: break   # per fact above
        period = period_of_repeating_decimal(n)
        if period > max_period:
            max_period = period
            n_with_max_period = n
    
    return n_with_max_period
Пример #2
0
 def test_30(self):
     self.assertEqual(period_of_repeating_decimal(30), 1)
Пример #3
0
 def test_20(self):
     self.assertEqual(period_of_repeating_decimal(20), 0)
Пример #4
0
 def test_7(self):
     self.assertEqual(period_of_repeating_decimal(7), 6)
Пример #5
0
 def test_5(self):
     self.assertEqual(period_of_repeating_decimal(5), 0)