初等数论及python应用

该博客记录了 Bruce Berndt 教授在伊利诺伊大学的数论课程内容,涉及素数理论、黎曼猜想、因子分解、数论运算、费马定理、中国剩余定理等核心概念,以及相应的证明题和Python实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文是美国伊利诺伊大学香槟分校(University of Illinois at Urbana-Champaign)的Bruce Berndt教授的数论课程的学习笔记。

《Elementary Number Theory》
《Elementary Number Theory》

Week 1

1. 概念

agreed-upon notations:

素数 prime: >=2

孪生素数 twin primes:If p and p + 2 are primes,∃无穷对

https://zh.wikipedia.org/wiki/%E5%AD%AA%E7%94%9F%E7%B4%A0%E6%95%B0

梅森素数 Mersenne prime: p is a prime and 2^p - 1 is a prime

π(x) = # of primes ≤ x,#表数量,=li x+△(x) (△(x)=O(√x (log(x))^2)为误差项error term)

li x= ∫_2^x dt/log(t) ∼ x/log(x)

渐进 f (x) is asymptotic to g(x) as x → ∞:lim f (x)/g(x) = 1 (x→∞)

Big-O:f (x) = O(g(x)) as x → ∞ if ∃C > 0 ∋ ∣f (x)∣ ≤ C ∣g(x)∣ for x suffciently large.

素数定理 Prime Number Theorem:As x → ∞, π(x) ∼ x/logx

https://zh.wikipedia.org/wiki/%E8%B3%AA%E6%95%B8%E5%AE%9A%E7%90%86

黎曼猜想 Riemann Hypothesis:All non-trivial zeroes of ζ(z) are on Re z = 1/2

https://zh.wikipedia.org/wiki/%E9%BB%8E%E6%9B%BC%E7%8C%9C%E6%83%B3

黎曼ζ函数 Riemann Zeta Function ζ(z)=∑1/n^x converges for x > 1,∑1/n^z  converges for Re z > 1,均是n=1到∞,it has an analytic continuation to the entire complex plane.

https://zh.wikipedia.org/wiki/%E9%BB%8E%E6%9B%BC%CE%B6%E5%87%BD%E6%95%B8

a b mod c:c ∣ (a - b)

r2(n) = # of representations of n as a sum of two squares, π(√x - 1)2 ≤ ∑n≤x r2(n) ≤ π(√x + 1)2

lattice point

分割函数 Partition P(n) = number of ways of writing n ∈ Z+ as a sum of positive integers.
Famous conjectures by Ramanujan:

  • P(5n + 4) ≡ O mod 5
  • P(7n + 5) ≡ O mod 7
  • P(11n + 6) ≡ O mod 11

辗转相除法/带余除法 Division Algorithm: Let a, b ∈ Z, b > 0. Then, ∃ unique q, r ∈ Z ∋ a = b q + r and 0 ≤ r < b.

爱拉托逊斯筛法 Sieve of Eratosthenes: want all primes ≤ x. List all integers up to x. Strike out every integer ≤ √x that’s a multiple of primes ≤ √x. (Because of the proposition: If n is composite, then ∃ at least one prime p ≤ √n dividing n.) Test primes p ∋ p ≤ √n. If none divide n, then n is prime.

最大公约数 Greatest Common Divisor(a, 0) = a, (a, 1) = 1, Let a, b ∈ Z, not both 0. Then, (a, b) = min{ma + nb > 0 ∶ m, n ∈ Z} > 0
最小公倍数 Least Common Multiple: [a,b], (a,b) [a,b] = ab

欧几里得算法 Euclidean Algorithm: Let a, b ∈ Z+, a ≥ b. Let a = b q + r, q, r ∈ Z. Then (a, b) = (b, r). Continue this process.

2. 小结论

A factorization:

3. 证明题

For n ∈ Z+, ∃ n consecutive composite numbers. Proof: (n + 1)! + 2, (n + 1)! + 3, . . . , (n + 1)! + (n + 1)

4.python代码

(1).基础数论运算:

math --- 数学函数 — Python 3.9.7 文档

包括gcd()、lcm():

import math
print(math.gcd(408,765))

pow(7, 1987)%11

(2).判断素数

def isPrime(n):    
    if n <= 1:    
        return False   
    i = 2   
    while i*i <= n:    
        if n % i == 0:    
            return False   
        i += 1   
    return True

(3).因式分解

import time

# 对一个数进行因式分解
def factorization(num):
    factor = []
    while num > 1:
        for i in range(num - 1):
            k = i + 2
            if num % k == 0:
                factor.append(k)
                num = int(num / k)
                break
    return factor

(4).两个正整数a,b的gcd=ax+by的表达式系数:

# gcd_integer_solution
def gcd_integer_solution(p, q):
    """
    求一个形如px+qy=gcd(p,q)(p、q均为正整数)方程的整数解的函数。
    Inputs:
       p, q: 方程左边的系数
    Outputs:
        x, y: 与p, q对应的未知数的解
    """
    # 递归终止条件: q等于0时
    if q == 0:
        return 1, 0  # 返回(1,0)——当方程右侧是gcd(p,q)时,最后的解肯定是(1,0)
    # 递归的过程:调用函数取出(n+1)轮的解(x,y),利用递推公式计算n轮的解(x,y)并return它
    ### 递归式子之前的过程是“向下递归”,之后的过程是“向上递归”
    else:
        x, y = gcd_integer_solution(q, p%q)  # (p,q)-->(q,p%q)的递归过程
        x, y = y, x - (p//q)*y  # 将(n+1)轮的解转换为n轮
        # a = y  # 将(n+1)轮的解转换为n轮,引入a是避免交叉赋值出错
        # y = x - (p//q)*a
        # x = a
        return x, y

(5).求一个形如px+qy=c(p、q均为正整数,c为整数)方程的整数解的函数:

# integer_solution
import math

def integer_solution(p, q, c):
    """
    求一个形如px+qy=c(p、q均为正整数,c为整数)方程的整数解的函数。
    Inputs:
        p, q: 方程左边的系数,输入正整数
        c: 方程右边的系数
    Outputs:
        x, y: 方程的解
    """
    gcd_p_q = math.gcd(p, q)
    # 只有在方程有解时才求解
    if c%gcd_p_q == 0:
        # 首先求解px+qy=gcd(p,q)
        x_gcd, y_gcd = gcd_integer_solution(p, q)
        # 然后转换为px+qy=c=gcd(p,q)*(c/gcd(p,q))的解
        x, y = x_gcd*(c/gcd_p_q), y_gcd*(c/gcd_p_q)    
        return x, y
    # 方程无解时返回两个None
    else:
        return None, None

(6).其他

/*
  Algorithm: 快速幂/Fermat, Solovay_Stassen, Miller-Rabin素性检验
*/
import random

def QuickPower(a, n, p): # 快速幂算法
    tmp = a
    ret = 1
    while(n > 0):
        if (n&1):
            ret = (ret * tmp) % p
        tmp = (tmp * tmp) % p
        n>>=1
    return ret

def Jacobi(n, m): # calc Jacobi(n/m)
    n = n%m
    if n == 0:
        return 0
    Jacobi2 = 1
    if not (n&1): # 若有n为偶数, 计算Jacobi2 = Jacobi(2/m)^(s) 其中n = 2^s*t t为奇数
        k = (-1)**(((m**2-1)//8)&1)
        while not (n&1):
            Jacobi2 *= k
            n >>= 1
    if n == 1:
        return Jacobi2
    return Jacobi2 * (-1)**(((m-1)//2*(n-1)//2)&1) * Jacobi(m%n, n)

def Fermat(x, T): # Fermat素性判定
        if x < 2:
                return False
        if x <= 3:
                return True
        if x%2 == 0 or x%3 == 0:
                return False
        for i in range(T):
                ran = random.randint(2, x-2) # 随机取[2, x-2]的一个整数
                if QuickPower(ran, x-1, x) != 1:
                        return False
        return True

def Solovay_Stassen(x, T): # Solovay_Stassen素性判定
    if x < 2:
        return False
    if x <= 3:
        return True
    if x%2 == 0 or x%3 == 0:
        return False
    for i in range(T): # 随机选择T个整数
        ran = random.randint(2, x-2)
        r = QuickPower(ran, (x-1)//2, x)
        if r != 1 and r != x-1:
            return False
        if r == x-1:
            r = -1
        if r != Jacobi(ran, x):
            return False
    return True

def MillerRabin(x, ran): # x-1 = 2^s*t
    tx = x-1
    s2 = tx&(~tx+1) # 取出最后一位以1开头的二进制 即2^s
    r = QuickPower(ran, tx//s2, x)
    if r == 1 or r == tx:
        return True
    while s2>1: # 从2^s -> 2^1 循环s次
        r = (r*r)%x
        if r == 1:
            return False
        if r == tx:
            return True
        s2 >>= 1
    return False

def MillerRabin_init(x, T): #Miller-Rabin素性判定
    if x < 2:
        return False
    if x <= 3:
        return True
    if x%2 == 0 or x%3 == 0:
        return False
    for i in range(T): # 随机选择T个整数
        ran = random.randint(2, x-2)
        if not MillerRabin(x, ran):
            return False
    return True

Week 2

1. 概念

Frequency of Prime Numbers:


 

算术基本定理 Fundamental Theorem of Arithmetic: Every integer a > 1 can be represented uniquely as a product of primes

狄利克雷定理 Dirichlet’s Theorem on Primes in Arithmetic Progressions: If (a, b) = 1, then {an + b ∶ n ≥ 0} has infinitely-many primes.

同余 congruent a b (mod m): a is congruent to b modulo m, m ∈ Z+, if m ∣ (a - b).

https://zh.wikipedia.org/wiki/%E5%90%8C%E9%A4%98

Congruence defines Equivalence Relation.

Arithmetic Properties of the Congruence Relation:
a ≡ b (mod m) , c ≡ d (mod m), then:

  • a + c ≡ b + d (mod m)
  • ac ≡ bd (mod m)

ca ≡ cb (mod m) ⇐⇒ a ≡ b (mod m/(c,m))

等价类 Equivalence Classes

完全剩余系 Complete Residue System: Complete Residue System modulo m is a set, S, of integers such that every n ∈ Z is congruent to one and only one member of S. 是一个由n个数组成的集合

既约剩余系/简化剩余系/缩系 Reduced Residue System: A reduced residue system modulo m is a set of integers r_1, ...,r_n such that if (a,m) = 1, then a ≡ r_j( mod m) for 1 and only 1 value of j, m的完全剩余系中与m互素的数构成的子集

Theorem on a Complete (Reduced) System: Let r_1, ..,r_n be a complete (reduced) system modulo m. Let (a,m) = 1. Then a·r_1, ...,a·r_n is a a complete (reduced) residue system modulo m

恰整除 exactly divide p^a||n: p^a|n and p^(a+1)∤n

2. 小结论

If p|n!, the exponent of p in the prime factorization of n! is [n/p] + [n/p^2] + [n/p^3] + ...

3. 证明题

Let n ∈ Z with n > 1. Prove that 1 + 1/2 + 1/3 + · · · + 1/n ∉ Z

4.python代码

Week 3

1. 概念

乘法逆元素 Multiplicative Inverse: A solution of ax ≡ 1( mod m) is a (multiplicative) inverse of a mod m). The linear congruence ax ≡ 1( mod m) has a solution (inverse) if (a, m) = 1 and the inverse is unique.

https://zh.wikipedia.org/wiki/%E6%A8%A1%E5%8F%8D%E5%85%83%E7%B4%A0

中国剩余定理 Chinese Remainder Thm

https://zh.wikipedia.org/wiki/%E4%B8%AD%E5%9B%BD%E5%89%A9%E4%BD%99%E5%AE%9A%E7%90%86

威尔逊定理 Wilson’s Theorem: p is prime ⇐⇒ (p - 1)! ≡ -1 (mod p) (p>1)

https://zh.wikipedia.org/wiki/%E5%A8%81%E5%B0%94%E9%80%8A%E5%AE%9A%E7%90%86
Let p be a prime, then the inverse of a modulo p is a ⇐⇒ a ≡ ±1 (mod p)

威尔逊质数 Wilson prime p: (p - 1)! ≡ -1 (mod p^2)

2. 小结论

求解ax ≡ b (mod m)

Let ax ≡ b (mod m). Let d = (a, m). If d ∤ b, then there are no solutions. If d ∣ b, then there exist exactly d incongruent solutions modulo m. Example:
481x ≡ 629( mod 703)
d=(481, 703) = 37,
37 ∣ 629, ∃37 solutions
629 = 37 ⋅ 17 = 3 ⋅ 17 ⋅ 481 - 2 ⋅ 17 ⋅ 703
x0=51, 703/37=19
∴ x=51+19n, n = 0, 1, ..., 36

3.证明题

If p ≡ 1 mod 4, we’ll show that p = a^2 + b^2.

4.python代码

(1).求模逆元

def     gcd(a,b):
        while a!=0:
            a,b = b%a,a
        return b
#定义一个函数,参数分别为a,n,返回值为b
def     findModReverse(a,m):#这个扩展欧几里得算法求模逆

        if gcd(a,m)!=1:
            return None
        u1,u2,u3 = 1,0,a
        v1,v2,v3 = 0,1,m
        while v3!=0:
            q = u3//v3
            v1,v2,v3,u1,u2,u3 = (u1-q*v1),(u2-q*v2),(u3-q*v3),v1,v2,v3
        return u1%m

#方法二:用定义求,但是效率很低
def findModReverse2(a,m):
    import itertools
    for b in itertools.count(1):
        if (a*b)%m==1:
            return b

(2).中国剩余定理(Chinese Remainder Theorem, CRT)

仅适用于互质情况

#!/usr/bin/env python
from functools import reduce

def egcd(a, b):
    """扩展欧几里得"""
    if 0 == b:
        return 1, 0, a
    x, y, q = egcd(b, a % b)
    x, y = y, (x - a // b * y)
    return x, y, q
def chinese_remainder(pairs):
    """中国剩余定理"""
    mod_list, remainder_list = [p[0] for p in pairs], [p[1] for p in pairs]
    mod_product = reduce(lambda x, y: x * y, mod_list)
    mi_list = [mod_product//x for x in mod_list]
    mi_inverse = [egcd(mi_list[i], mod_list[i])[0] for i in range(len(mi_list))]
    x = 0
    for i in range(len(remainder_list)):
        x += mi_list[i] * mi_inverse[i] * remainder_list[i]
        x %= mod_product
    return x
print(chinese_remainder([(3, 2), (5, 3), (7, 2)]))

Week 4

1. 概念

费马小定理 Fermat’s Little Theorem: If p is a prime and p ∤ a, then a^(p-1) ≡ 1 (mod p)

费马数 Fermat number F_n: =2^(2^n)+1

https://zh.wikipedia.org/wiki/%E8%B2%BB%E9%A6%AC%E6%95%B8

伪素数 pseudoprime n: 2^n ≡ 2(mod n)

Euler’s Φ-function Φ(n) = ∣{j ∈ Z, 1 ≤ j ≤ n, (j, n) = 1}∣

欧拉定理 Euler’s Theorem: Let {a, m} ∈ Z, m > 0, (a, m) = 1. Then a^Φ(m) ≡ 1(mod m)

https://zh.wikipedia.org/wiki/%E6%AC%A7%E6%8B%89%E5%AE%9A%E7%90%86_(%E6%95%B0%E8%AE%BA)

a^(Φ(m)-1) is the inverse of a(mod m)

Φ(p^a)=p^a-p^(a-1)

算术函数 Arithmetic functions a(n): are functions whose domains are the positive integers.
d(n) = # of divisors of n.
σ_a (n) = sum of the a^th powers of the divisors of n.
r_k (n) = # of representations of n as a sum of k squares.

积性函数 multiplicative a(n): if whenever (m, n) = 1, then a(mn) = a(m) a(n)

https://zh.wikipedia.org/wiki/%E7%A9%8D%E6%80%A7%E5%87%BD%E6%95%B8
If f (n) is multiplicative, then \mathbf{F(n) = \sum_{d|n} f(d)} is also multiplicative.
Φ(mn) = Φ(m)Φ(n) whenever (m,n) = 1

完全积性函数 completely multiplicative: If we can remove the restriction (m, n) = 1 and still have a(mn) = a(m) a(n).

加性函数 additive a(n): a(m + n) = a(m) + a(n)

https://zh.wikipedia.org/wiki/%E5%8A%A0%E6%80%A7%E5%87%BD%E6%95%B8

2. 小结论

(r,m)=1 ⇐⇒ there exists an integer such that ar+bm=1

Let p be a prime, and p ∤ a, then the inverse of a mod p is a^(p-2).

For all a and primes p, a^p ≡ a mod p.

Week 5

1. 概念

除数函数 The Divisor function: v(n)=τ(n)=d(n)=\sum_{d|n}1

https://zh.wikipedia.org/wiki/%E9%99%A4%E6%95%B8%E5%87%BD%E6%95%B8

d(n) is multiplicative.

d(p^a)=a+1, for every prime p and positive integer a.

Sum of the Divisors Function σ(n)=\sum_{d|n}d, σ(n) is multiplicative.

奇完全数 Perfect Numbers: n is perfect if σ(n) = 2n, i.e., n is perfect if the sum of the proper divisors of n is n.

n is an even perfect number ⇐⇒ n = 2^{(p-1)}(2^p - 1)n = 2^(p-1) · (2^p - 1), where p, 2^p - 1 are both primes.
n is perfect if σ(n) = 2n.

默比乌斯函数 Mobius Function μ(n):

https://zh.wikipedia.org/wiki/%E9%BB%98%E6%AF%94%E4%B9%8C%E6%96%AF%E5%87%BD%E6%95%B0

μ(n) is multiplicative.

莫比乌斯求逆公式  Mobius Inversion Formula:

Riemann zeta Function ζ(s):

二次剩余 quadratic residue: Let (a, m) = 1, m > 1. a is a quadratic residue modulo m if x^2 ≡ a mod m has a solution.

二次非剩余 quadratic nonresidue

Let p be an odd prime. Then x^2 ≡ a mod p, p ∤ a has either 2 incongruent solutions or 0 solutions.

Let p be an odd prime. Then ∃ (p-1)/2 quadratic residues mod p and (p-1)/2 quadratic nonresidues mod p.

2.python代码

判断是否为二次剩余以及求二次剩余

def euler_criterion(a, p):
    """p is odd prime, a is positive integer. Euler's Criterion will check if
	a is a quadratic residue mod p. If yes, returns True. If a is a non-residue
	mod p, then False"""
    return pow(a, (p - 1) // 2, p) == 1

def results(a):
    for i in range(1,a):
        if euler_criterion(i, a):
            print(i)
    return

print(euler_criterion(5,11))
print(results(11))

Week 6

1. 概念

勒让德符号 Legendre symbol {\color{Red}(\frac{a}{p}) }:(≡0时,值为0)

https://zh.wikipedia.org/wiki/%E5%8B%92%E8%AE%A9%E5%BE%B7%E7%AC%A6%E5%8F%B7

欧拉准则 Euler’s Criterion: Let p be odd prime, p ∤ a. Then (\frac{a}{p})=1\Leftrightarrow a^{\frac{p-1}{2}}\equiv1mod\: p .

https://zh.wikipedia.org/wiki/%E6%AC%A7%E6%8B%89%E5%87%86%E5%88%99

高斯引理 Gauss’s Lemma: Let p be an odd prime, p ∤ a. Let n = the number of least positive residues of a, 2a, 3a, . . . , (p−1)a/2 that are > p/2. Then ( a/p ) = (−1)^n.

二次互反性 Law of Quadratic Reciprocity: Let p, q be distinct, odd primes, then:

https://zh.wikipedia.org/wiki/%E4%BA%8C%E6%AC%A1%E4%BA%92%E5%8F%8D%E5%BE%8B#50%E4%BB%A5%E5%86%85%E7%9A%84%E8%B4%A8%E6%95%B0%E7%9A%84%E4%BA%8C%E6%AC%A1%E5%89%A9%E4%BD%99%E8%A1%A8

The Legendre–Jacobi Symbol (P/Q): P, Q integers , Q > 0 and odd, P Q ≠ 0. Q = q1q2 ⋯qs (product representation of Q into primes), then:

Let P, P′ ∈ Z, P ≠ 0, Q, Q′ are odd and positive. Then:

Week7

1. 概念

阶 Order of a mod m {\color{Red} ord_{m}a}: the smallest positive integer n such that \mathbf{a^n\equiv 1 \: mod\: m}.

ord_{m}a\: \leq \: \phi(m)

Let (a, m) = 1, m > 0. If a^n\equiv 1 \: mod\: m, then ord_{m}a\: |\: n.
A corollary would be that \mathbf{ord_{m}a\: |\: \phi(m)}.

Let (a, m) = 1, m > 0. Let i, j ≥ 0, i, j ∈ Z, then a^i\equiv a^j \; mod\; m\Leftrightarrow i\equiv j \; mod\; ord_{m}a.

(r, m) = 1, r^Φ(m) ≡ 1 mod m

原根 primitive rootr is a primitive root mod m if ord_m r = Φ(m).
imprimitive root: r is an imprimitive root mod m if ord_m r < Φ(m).

https://zh.wikipedia.org/wiki/%E5%8E%9F%E6%A0%B9

If r is a primitive root, then a set of reduce residues mod m is {r, r^2, . . . , r_Φ(m)}.

Let (a, m) = 1, m > 0, n ∈ Z+, then \mathbf{ord_{m}a^n=\frac{ord_{m}a}{(ord_{m}a,n)}}
Let (a, m) = 1, m > 0, n ∈ Z+, then ord_{m}a^n=ord_{m}a\Leftrightarrow (ord_{m}a,n)=1.

If a primitive root r mod m exists, then ∃ exactly Φ(Φ(m)) primitive roots mod m.计算原根数量

拉格朗日定理 Lagrange's Theorem: Let p be a prime. Let f(x) = , a_j ∈ Z, p ∤ a_n. Then f(x) ≡ 0 mod p has at most n incongruent solutions mod p.

Let p be a prime, d ∣ (p - 1). Then x^d - 1 ≡ 0 mod p has exactly d incongruent solutions mod p.

Let p be a prime, d ∈ Z+, d ∣ (p - 1). Then ∃ exactly Φ(d) incongruent integers having order d mod p.

∃ ∞-many primes for which 2 is the least primitive root.

Week 8

1. 概念

Theorem for Linear Diophantine Equations with Two Variables: Consider ax + by = c, where a, b, c ∈ Z ; d = (a, b). If d ∤ c, then 不∃ solutions. If d ∣ c, then ∃ infinitely many solutions.
Let (x0, y0) be a solution, then all solutions are given by x = x0 + nb/d ; y = y0 - na/d, n ∈ Z.

线性丢番图方程 linear Diophantine equation a1x1 + a2x2 + ::: + anxn = c:
1. x^2 + y^2 = z^2 (勾股方程 Pythagorean equation)
2. x^n + y^n = z^n; n ≥ 3 solved 1995, Andrew Wiles, no solutions
3. x^2 - dy^2 = n
4. x^3 + y^3 = w^3 + z^3 (taxicab equation)

本原勾股数 primitive Pythagorean triple (x, y, z): x^2 + y^2 = z^2 and (x, y, z)=1.
∃ infinitely many primitive Pythagorean triples with y even and they are given by:
x = m^2 - n^2
y = 2mn
z = m^2 + n^2
where m, n > 0 , m, n ∈ Z , (m, n) = 1 and one of them is even

Fermat’s Last Theorem

四平方和定理 Lagrange's four-square theorem:每个正整数均可表示为4个(不全为零的)整数的平方和。

2. 小结论

x^4+y^4=z^2 has no nonzero solutions in integers.

If n1, n2 can be written as a sum of 2 squares then n1n2 can be also written as a sum of 2 squares.

Let p be prime , p ≡ 1( mod 4). then ∃x; y ∈ Z; k ∈ Z+ such that x^2 + y^2 = kp.

Every prime p ≡ 1( mod 4) is expressible as a sum of 2 squares. Also p = 2 is so expressible.

Let n ∈ Z+. Then n = a^2 + b^2 ⇐⇒ each prime in the factorization of n that is ≡ 3( mod 4) has even exponent.

N = 4^m*(8n + 7) cannot be represented as a sum of 3 squares m = n = 0 N = 7.

Let n1, n2 be each expressible as a sum of 4 squares. Then n1n2 can be represented as a sum of 4 squares.

Let p be an odd prime, then there ∃x, y, k ∈ Z , 0 < k < p such that x^2 + y^2 + 1 = kp.

If p is a prime, then p = w^2 + x^2 + y^2 + z^2.

3.程序

将一个数表示为两个平方数之和

#遍历
def judgeSquareSum(c: int) -> bool:
    is_square = lambda n: not n ** 0.5 % 1      # 定义函数,判断一个数是不是平方数
    for i in range(int(c**0.5)+1):              # 遍历数字,注意范围
        if is_square(c-i**2):                   # 如果c-i^2是平方数
            return True                         # 返回True
    return False                                # 不满足平方数之和的条件
#左右指针
def judgeSquareSum(c: int) -> bool:
    left, right = 0, int(c**0.5)+1              # 定义左右指针
    while left <= right:                        # 如果左指针没有跑到右指针右边
        rst = left * left + right * right       # 计算平方和
        if rst == c:                            # 如果平方和恰好等于结果
            return True                         # 说明目标值c是平方和
        elif rst < c:                           # 如果当前平方比目标值小
            left += 1                           # 左指针右移
        elif rst > c:                           # 如果当前平方比目标值大
            right -= 1                          # 右指针左移
    return False                                # 没有找到,返回False

多项式方程求解

import numpy as np

p = np.array([1,-15,0,10,4,3])

b = np.roots(p)#求根
print(b)

r = np.real(b)#取实数
print(r)

Week 9

1. 概念

A character χ(n) has period p (prime) and is multiplicative, values are roots of unity, χ(n) = 0 if (n, p) > 1. χ(n) ≡ 1 trivial character.

高斯和 Gauss Sum G(α,χ)=

https://zh.wikipedia.org/wiki/%E9%AB%98%E6%96%AF%E5%92%8C
where α is an integer. G(1, χ) = G(χ).
G(α,χ) = χ(α^-1) G(χ), provided α ≠ 0 and α ≠ np.
=χ(-1)p where χ is nontrivial and α ≡/ 0
|G(α,χ)|=√p

g(β):

简单连分数 simple continued fraction [a0, a1, . . . , an]: if a1, . . . , an are positive integers and a0 ∈ Z.

Let α ∈ R. Then α ∈ Q ⇐⇒ α can be expressed as a finite simple continued fraction.

Let α = [a0, a1, . . . , an]. Let (pj, qj) = 1, 0 ≤ j ≤ n.

Let α be as before. Then C0 < C2 < C4 < ⋯C5 < C3 < C1.

q_j ≥ j, j ≥ 0.

Let α ∈ R. Then α ∈ R / Q ⇐⇒ α can be expressed as an infinite simple continued fraction.

Let α ∈ R / Q. Then the representation of α as an infinite continued fraction is unique.

Let α ∈ R / Q. Let p_n/q_n be the nth convergent to α. Let a, b ∈ Z, 0 < b < q_(n+1). Then ∣q_n α - p_n∣ ≤ ∣bα - a∣.

Let α ∈ R / Q. Let p_j/q_j be the jth convergence of a simple continued fraction of α. Let a, b ∈ Z, 1 ≤ b ≤ q_j. Then ∣α - p_j/q_j∣ ≤ ∣α - a/b∣.

[a0, a1, a2, . . .] is eventually periodic if ∃ positive integers N, P such that a_n = a_(n+p), n ≥ N.

2. 小结论

√2 is irrational

github上的项目

GitHub - Robert-Campbell-256/Number-Theory-Python: Python code to implement various number theory, elliptic curve and finite field computations.

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值