当前位置:网站首页>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
边栏推荐
- Nc100 converts strings to integers (ATOI)
- CPI tutorial - asynchronous interface creation and use
- IOS interview
- ASTM D 3801固体塑料垂直燃烧试验
- [20211129] jupyter notebook remote server configuration
- 腾讯安全联合毕马威发布监管科技白皮书,解析“3+3”热点应用场景
- Perl 5.10.0 installation package download
- 6.30模拟赛总结
- fatal error: execution: 没有那个文件或目录
- R language uses conf of yardstick package_ The mat function calculates the confusion matrix of the multiclass model on each fold of each cross validation (or resampling), and uses the summary to outpu
猜你喜欢
![[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

晓看天色暮看云,美图欣赏

logstash报错:Cannot reload pipeline, because the existing pipeline is not reloadable

Switch basic experiment

leetcode:226. 翻转二叉树【dfs翻转】

IOS interview

队列的链式存储

《MATLAB 神经网络43个案例分析》:第40章 动态神经网络时间序列预测研究——基于MATLAB的NARX实现

基因检测,如何帮助患者对抗疾病?

Nc100 converts strings to integers (ATOI)
随机推荐
Chain storage of binary tree
Blocking sockets的读写操作该怎么玩?
CPI教程-异步接口创建及使用
QT 播放器之列表[通俗易懂]
Huawei interview question: Recruitment
leetcode:226. Flip binary tree [DFS flip]
R language uses conf of yardstick package_ The mat function calculates the confusion matrix of the multiclass model on each fold of each cross validation (or resampling), and uses the summary to outpu
IOS interview
GID:旷视提出全方位的检测模型知识蒸馏 | CVPR 2021
Tencent Li Wei: deeply cultivate "regulatory technology" to escort the steady and long-term development of the digital economy
redis探索之缓存击穿、缓存雪崩、缓存穿透
基于.NetCore开发博客项目 StarBlog - (13) 加入友情链接功能
"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
Double linked list related operations
Need your own cognition
be based on. NETCORE development blog project starblog - (13) add friendship link function
Chapter 14 signals (IV) - examples of multi process tasks
[Suanli network] technological innovation of Suanli Network -- key technology of operation service
logstash报错:Cannot reload pipeline, because the existing pipeline is not reloadable
《MATLAB 神经网络43个案例分析》:第40章 动态神经网络时间序列预测研究——基于MATLAB的NARX实现