当前位置:网站首页>HJ prime factor
HJ prime factor
2022-06-28 07:38:00 【Courageous steak】
describe
function : Enter a positive integer , Output all its quality factors from small to large ( Repeat it )( Such as 180 The qualitative factor of is 2 2 3 3 5 )
Data range :1≤n≤2×109+14
Input description :
Enter an integer
Output description :
Output the factors of all its prime numbers in descending order , Space off .
Example 1
Input :180
Output :2 2 3 3 5
Prime factor interpretation :
Baidu Encyclopedia :https://baike.baidu.com/item/%E8%B4%A8%E5%9B%A0%E5%AD%90/10720836?fr=aladdin
Concept :
- A number can be represented by all its prime factors
solution :
- The range of prime numbers must be Under the root n
- n Divide by all prime factors , The result is 1:24/2/2/2/3=1
Cattle guest HJ Python
import math
n = int(input())
for i in range(2, int(math.sqrt(n) + 1)):
while n % i == 0:
print(i, end=" ")
n = n // i
# Print the remaining prime numbers
if n > 2:
print(n)
Link to the original text :
边栏推荐
猜你喜欢

hack the box:RouterSpace题解

Practice of traffic recording and playback in vivo

Safety training is the greatest benefit for employees! 2022 induction safety training for new employees

卸载重装最新版mysql数据库亲测有效

Kubernetes理论基础

Spark 离线开发框架设计与实现

Kubernetes deploys a secret pit where thanos ruler sends repeated alarms

Resizing node of rediscluster cluster cluster mode

In idea, the get and set methods may be popular because the Lombok plug-in is not installed

PLC -- Notes
随机推荐
安全培训是员工最大的福利!2022新员工入职安全培训全员篇
自动化测试的生命周期是什么?
卸载重装最新版mysql数据库亲测有效
R 和 rgl 绘制 3D 结
ABAP 技能树
Section 9: dual core startup of zynq
HJ21 简单密码
golang gin框架进行分块传输
Practice of traffic recording and playback in vivo
Understanding of OPC protocol
Spark 离线开发框架设计与实现
The practice of event driven architecture in vivo content platform
A gadget can write crawlers faster
Analyze 5 indicators of NFT project
网传互联网公司加班表,排名第一的没悬念
NDK cross compilation
What is the lifecycle of automated testing?
8 张图 | 剖析 Eureka 的首次同步注册表
R 语言 ggmap
什么是EC鼓风机(ec blower fan)?