From 6fe1881e82586b695e164e86cc1d3987cfe15ee6 Mon Sep 17 00:00:00 2001 From: "xw_y_am@rmbp" Date: Wed, 13 Sep 2017 17:48:19 +0800 Subject: [PATCH] add 131 133 135 137 --- python/120.py | 0 python/131.1.py | 33 +++++++++++++++++++++++++++++++ python/131.md | 13 +++++++++++++ python/131.py | 12 ++++++++++++ python/133.1.py | 32 ++++++++++++++++++++++++++++++ python/135.1.py | 8 ++++++++ python/137.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ python/137.py | 19 ++++++++++++++++++ 8 files changed, 169 insertions(+) mode change 100755 => 100644 python/120.py create mode 100644 python/131.1.py create mode 100644 python/131.md create mode 100644 python/131.py create mode 100644 python/133.1.py create mode 100644 python/135.1.py create mode 100644 python/137.md create mode 100644 python/137.py diff --git a/python/120.py b/python/120.py old mode 100755 new mode 100644 diff --git a/python/131.1.py b/python/131.1.py new file mode 100644 index 0000000..06fb237 --- /dev/null +++ b/python/131.1.py @@ -0,0 +1,33 @@ +from tools import number_theory +import math + +def try_root(n): + root = int(n ** 0.5) + if root ** 2 == n: + return root + raise ValueError + +def solve(p, k): + num, mod = divmod((3 * k + try_root(k * (4 * p - 3 * k))) * k, 2 * (p - 3 * k)) + if not mod: + return num + raise ValueError + +def try_n(p, offset): + for k in range(int(p * offset) + 1, p // 3 + 1): + try: + return solve(p, k), k / p + except: + pass + +def find(limit): + offset = 0 + for p in number_theory.make_prime(limit): + try: + solve, offset = try_n(p, offset) + print(solve, offset) + yield solve + except: + pass + +print(list(find(1000000))) diff --git a/python/131.md b/python/131.md new file mode 100644 index 0000000..76ceb8a --- /dev/null +++ b/python/131.md @@ -0,0 +1,13 @@ +$$ +m^3=n^3+n^2p +$$ + +let $m=n+k$ , then +$$ +3n^2k+3nk^2+k^3=n^2p\\ +(p-3k)n^2-3k^2n-k^3=0 +$$ +witch $p>3k$ . solving this function, we get +$$ +n = \frac{3k^2 \pm k\sqrt{4kp-3k^2}}{p-3k} +$$ diff --git a/python/131.py b/python/131.py new file mode 100644 index 0000000..7494e64 --- /dev/null +++ b/python/131.py @@ -0,0 +1,12 @@ + +from tools import number_theory + +_eps = 0.0000000000001 + +def n_peak(p): + for n in range(1, p): + right = n ** 3 + p * (n ** 2) + m = int(right ** (1 / 3) + _eps) + print(n, m, right - m ** 3) + +print(n_peak(19)) diff --git a/python/133.1.py b/python/133.1.py new file mode 100644 index 0000000..6ed75c3 --- /dev/null +++ b/python/133.1.py @@ -0,0 +1,32 @@ +from tools import number_theory + +def unit(p): + base = 1 + loop = 1 + while True: + base %= p + if not base: + return loop + base = 10 * base + 1 + loop += 1 + +def is_dec(num): + while not num % 2: + num //= 2 + while not num % 5: + num //= 5 + return 1 == num + +def statistic(limit): + prime = number_theory.make_prime(limit) + next(prime) + next(prime) + next(prime) + for p in prime: + if is_dec(unit(p)): + yield p + +#print(list(statistic(100000))) +get = [11, 17, 41, 73, 101, 137, 251, 257, 271, 353, 401, 449, 641, 751, 1201, 1409, 1601, 3541, 4001, 4801, 5051, 9091, 10753, 15361, 16001, 19841, 21001, 21401, 24001, 25601, 27961, 37501, 40961, 43201, 60101, 62501, 65537, 69857, 76001, 76801] + +print(sum(set(number_theory.make_prime(100000)) - set(get))) diff --git a/python/135.1.py b/python/135.1.py new file mode 100644 index 0000000..722829b --- /dev/null +++ b/python/135.1.py @@ -0,0 +1,8 @@ +''' +let x = y + d, z = y - d +then x**2 - y**2 - z**2 = n can be written b**2 - 4bd + n = 0 +so b = 2d +- sqrt(4 * d**2 - n) +let t**2 = 4 * d**2 - n, then (2d + t) * (2d - t) = n +''' + +def dual_factor(num): diff --git a/python/137.md b/python/137.md new file mode 100644 index 0000000..a576704 --- /dev/null +++ b/python/137.md @@ -0,0 +1,52 @@ +$$ +A_F(x)= xF_1+x^2F_2+x^3F_3\cdots +$$ + +$$ +xA_F(x)= \; x^2F_1+x^3F_2+x^4F_3+\cdots +$$ + +$(1)+(2)$, and consider that $F_1=F_2$, then we have +$$ +(1+x)A_F(x)=xF_2+x^2F_2+x^3F_3+\cdots +$$ +so +$$ +x(1+x)A_F(x)=A_F(x)-xF_1 +$$ +then +$$ +A_F(x)=\frac{x}{1-x-x^2} +$$ +we want that $A_F(x)$ could be a nature number, so let +$$ +\frac{x}{1-x-x^2}=n +$$ +then +$$ +nx^2+(n+1)x-n=0 +$$ +solve this, get +$$ +x=\frac{\sqrt{5n^2+2n+1}-(n+1)}{2n} +$$ +only $5n^2+2n+1$ is square number that can make x to be a rational. + +let's try to analyse how $n$ increasing when $5n^2+2n+1$ is square number. + +| n | increasing rate of n | +| ---------- | -------------------- | +| 2 | | +| 15 | 7.5 | +| 104 | 6.933333333 | +| 714 | 6.865384615 | +| 4895 | 6.855742297 | +| 33552 | 6.854341164 | +| 229970 | 6.854136862 | +| 1576239 | 6.854107057 | +| 10803704 | 6.854102709 | +| 74049690 | 6.854102075 | +| 507544127 | 6.854101982 | +| 3478759200 | 6.854101969 | + +it is obvious that the rate of $n$ is converge to $6.8541\cdots$ . with using search engein we know $\varphi^4=6.8541\cdots$ and $\varphi=\frac{\sqrt{5}-1}{2}$. \ No newline at end of file diff --git a/python/137.py b/python/137.py new file mode 100644 index 0000000..17a3eb2 --- /dev/null +++ b/python/137.py @@ -0,0 +1,19 @@ + +def fib_jump(): + a, b = 13, 21 + while True: + yield a + for i in range(4): + a, b = b, a + b + + +def search(limit): + n = 2 + for jump in fib_jump(): + yield n + n += jump + limit -= 1 + if not limit: + return + +print(list(search(15))[-1])