当前位置:网站首页>Fundamentals of number theory and its code implementation
Fundamentals of number theory and its code implementation
2022-07-01 12:41:00 【51CTO】
List of articles
- Euclid
- Minimum common multiple
- Sieve to find the prime number ( Prime sieve )
- Basic theorem of arithmetic
- The permutation number of multiple sets
Euclid
Minimum common multiple
Sieve to find the prime number ( Prime sieve )
# Sieve to find prime number O(N)
# You can get 2-n The prime number in 1 Not prime
N
=
100010
primes
= [
0
for
i
in
range(
N)]
# Existential prime
st
= [
0
for
i
in
range(
N)]
# Has the current number been screened 0 Represents not being screened It shows that the number is a prime number Otherwise, it's not
def
get_primes(
n):
cnt
=
0
# Prime subscript
for
i
in
range(
2,
n
+
1):
if
not
st[
i]:
primes[
cnt]
=
i
cnt
+=
1
j
=
0
while
primes[
j]
*
i
<=
n:
st[
primes[
j]
*
i]
=
1
if
i
%
primes[
j]
==
0:
break
j
+=
1
get_primes(
100000)
for
i
in
range(
20):
print(
primes[
i])
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
Basic theorem of arithmetic
Every Greater than 1 The natural number of , If it's not itself, it's a prime number , It can be written as 2 More than one Prime number Product of , And after these qualitative factors are arranged in size , There is only one way to write .
for example 6 It can be written. 2 * 3
The permutation number of multiple sets
such as 1 1 2 2 3 What is the number of permutations
5! / 2! 2!1! = 10
边栏推荐
- Huawei interview question: Recruitment
- 微信模拟地理位置_伪装微信地理位置
- 79. Word search [DFS + backtracking visit + traversal starting point]
- Friends day 2022
- 腾讯黎巍:深耕“监管科技”,护航数字经济行稳致远
- 运行Powershell脚本提示“因为在此系统上禁止运行脚本”解决办法
- 華為面試題: 招聘
- Good luck brought by years of persistence
- Common chart usage of Bi tools
- [today in history] July 1: the father of time sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world
猜你喜欢
![[today in history] July 1: the father of time sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world](/img/41/76687ea13e1722654b235f2cfa66ce.png)
[today in history] July 1: the father of time sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world

IOS interview

codeforces -- 4B. Before an Exam

Sleep quality today 79 points

【历史上的今天】7 月 1 日:分时系统之父诞生;支付宝推出条码支付;世界上第一支电视广告

Double linked list related operations
![[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn](/img/f2/7931952b832e84d7b8f2615906f33f.png)
[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn
![[20211129] configuration du serveur distant du carnet de notes jupyter](/img/7c/79c9fcb91bde75e954dc3ecf9f5afd.png)
[20211129] configuration du serveur distant du carnet de notes jupyter
![[20211129] jupyter notebook remote server configuration](/img/7c/79c9fcb91bde75e954dc3ecf9f5afd.png)
[20211129] jupyter notebook remote server configuration

使用nvm管理nodejs(把高版本降级为低版本)
随机推荐
"Analysis of 43 cases of MATLAB neural network": Chapter 40 research on prediction of dynamic neural network time series -- implementation of NARX based on MATLAB
Circular linked list--
[Suanli network] technological innovation of Suanli Network -- key technology of operation service
The difference between memcpy and strcpy
leetcode:241. Design priority for operation expression [DFS + Eval]
[datawhale202206] pytorch recommendation system: multi task learning esmm & MMOE
Ansible的playbook
2022-06-28-06-29
79. Word search [DFS + backtracking visit + traversal starting point]
木架的场景功能
买卖其实也有风险
Arm GIC (V) how arm TrustZone supports security interrupt analysis notes.
leetcode:329. The longest incremental path in the matrix [DFS + cache + no backtracking + elegance]
【邂逅Django】——(二)数据库配置
【脑洞大开】《西潮》及《走向世界丛书》
Chapter 14 signals (IV) - examples of multi process tasks
[JS] interview questions
Compile and debug net6 source code
关于NAND FLASH解扣的认识
Share several tools for designing exquisite circuit diagrams