From 4a67c4295a17ee97bb38d3b75f7c827f004fe4c2 Mon Sep 17 00:00:00 2001 From: Licsber Date: Sun, 10 Apr 2022 05:47:28 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=A4=8D=E7=9B=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lanqiao/series13sheng/retry_tb.py | 101 ++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 lanqiao/series13sheng/retry_tb.py diff --git a/lanqiao/series13sheng/retry_tb.py b/lanqiao/series13sheng/retry_tb.py new file mode 100644 index 0000000..5e6c10f --- /dev/null +++ b/lanqiao/series13sheng/retry_tb.py @@ -0,0 +1,101 @@ +import math + +nums = [ + [2, 1], + [3, 2], + [4, 1], + [5, 4], + [6, 5], + [7, 4], + [8, 1], + [9, 2], + [10, 9], + [11, 0], + [12, 5], + [13, 10], + [14, 11], + [15, 14], + [16, 9], + [17, 0], + [18, 11], + [19, 18], + [20, 9], + [21, 11], + [22, 11], + [23, 15], + [24, 17], + [25, 9], + [26, 23], + [27, 20], + [28, 25], + [29, 16], + [30, 29], + [31, 27], + [32, 25], + [33, 11], + [34, 17], + [35, 4], + [36, 29], + [37, 22], + [38, 37], + [39, 23], + [40, 9], + [41, 1], + [42, 11], + [43, 11], + [44, 33], + [45, 29], + [46, 15], + [47, 5], + [48, 41], + [49, 46], +] + + +def check(number): + for num, mod in nums: + a, b = divmod(number, num) + if b != mod: + print(f"{number} % {num} == {number % num} != {mod}") + return False + + print(f"{number}: pass.") + return True + + +def lcm(a, b): + return a * b // math.gcd(a, b) + + +def cal_prime_nums(n): + prime = [1] * (n + 1) + prime[0] = prime[1] = 0 + for i in range(2, n + 1): + j = i * i + while j <= n: + prime[j] = 0 + j += i + + res = [] + for idx, num in enumerate(prime): + if num: + res.append(idx) + + return res + + +ans = 2022040920220409 +check(ans) + +prime = cal_prime_nums(99) +ans = 1 +product = 1 +for num, mod in nums: + while ans % num != mod: + ans += product + + product = lcm(product, num) + print(f"{ans} % {num} == {mod}") + +print(ans) +check(ans)