当前位置:网站首页>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
边栏推荐
- 系统测试UI测试总结与问题(面试)
- [datawhale202206] pytorch recommendation system: precision model deepfm & DIN
- 天青色等烟雨
- leetcode:226. Flip binary tree [DFS flip]
- Simple Fibonacci (recursive)
- MySQL common functions
- [shell programming] - shell introductory learning
- Double linked list related operations
- Ikvm of toolbox Net project new progress
- [datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn
猜你喜欢
![leetcode:226. Flip binary tree [DFS flip]](/img/b8/6c5596ac30de59f0f347bb0bddf574.png)
leetcode:226. Flip binary tree [DFS flip]

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

How to install php7 and perform performance test using yum
![[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn](/img/f2/7931952b832e84d7b8f2615906f33f.png)
[datawhale202206] pytorch recommendation system: recall model DSSM & youtubednn

BIM and safety in road maintenance-buildSmart Spain

使用nvm管理nodejs(把高版本降级为低版本)

Switch basic experiment

MySQL workbench data modeling function

redis探索之缓存一致性

工具箱之 IKVM.NET 项目新进展
随机推荐
redis探索之缓存一致性
leetcode:329. 矩阵中的最长递增路径【dfs + cache + 无需回溯 + 优雅】
6.30 simulation summary
ASTM D 3801 vertical burning test of solid plastics
The difference between memcpy and strcpy
Tencent security released the white paper on BOT Management | interpreting BOT attacks and exploring ways to protect
腾讯安全发布《BOT管理白皮书》|解读BOT攻击,探索防护之道
2022-06-28-06-29
哪个券商公司开户佣金低又安全又可靠
手把手教你完成图像分类实战——基于卷积神经网络的图像识别
[20211129] jupyter notebook remote server configuration
ASTM D 3801固体塑料垂直燃烧试验
Operations related to sequence table
R语言使用yardstick包的conf_mat函数计算多分类(Multiclass)模型在每个交叉验证(或者重采样)的每一折fold上的混淆矩阵、并使用summary输出每个fold的其它详细指标
Topic 1004: the story of cows (recursion)
華為面試題: 招聘
关于NAND FLASH解扣的认识
[brain opening] west tide and going to the world series
微信小程序 – 80个实用的微信小程序项目实例
木架的场景功能