当前位置:网站首页>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 :
边栏推荐
- 看似简单的光耦电路,实际使用中应该注意些什么?
- Introduction and several months' experience of extending the solution thanos of Prometheus
- Source code analysis of kubernetes' process of deleting pod
- Disposition Flex
- linux下修改mysql用户名root
- HJ质数因子
- What is the lifecycle of automated testing?
- Is it reliable to register and open an account for stock speculation? Is it safe?
- Ice - resources
- 网传互联网公司加班表,排名第一的没悬念
猜你喜欢
随机推荐
8 figures | analyze Eureka's first synchronization registry
基金的投资交易与结算
协程、asyncio、异步编程
Top 25 most popular articles on vivo Internet technology in 2021
What should I do if the version is incompatible with the jar package conflict?
东方财富上开户是安全的吗
阿里云服务器创建快照、回滚磁盘
Leetcode+ 66 - 70 high precision, two sub topics
QT -- 通讯协议
Makefile
R 和 rgl 绘制 3D 结
[ thanos源码分析系列 ]thanos query组件源码简析
HJ整数与IP地址间的转换
kubelet垃圾(退出的容器和未使用的镜像)回收源码分析
扩展Prometheus的解决方案thanos的简介和几个月使用心得
PLC -- Notes
R language drawing ggplot2 seasonal graph
es6箭头函数中return的用法
LLVM 与 Clang
linux下修改mysql端口号








