当前位置:网站首页>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 :
边栏推荐
- 大型项目中的Commit Message规范化控制实现
- Application and Optimization Practice of redis in vivo push platform
- 8 张图 | 剖析 Eureka 的首次同步注册表
- Is it safe to open an account on Dongfang fortune
- HJ删除字符串中出现次数最少的字符
- Kubernetes theoretical basis
- Kubernetes deploys a secret pit where thanos ruler sends repeated alarms
- es6箭头函数中return的用法
- Investment transaction and settlement of the fund
- The practice of traffic and data isolation in vivo Reviews
猜你喜欢

异或的应用。(提取出数字中最右侧的1,面试中经常用的到)

Resizing node of rediscluster cluster cluster mode

kubelet驱逐机制的源码分析

2021 programming language ranking summary

Sword finger offer|: linked list (simple)

ABAP skill tree

kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑

Source code analysis of kubernetes' process of deleting pod

es6箭头函数中return的用法

Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)
随机推荐
一个小工具可以更快的写爬虫
No suspense about the No. 1 Internet company overtime table
HTTP Caching Protocol practice
Section 5: zynq interrupt
Sword finger offer|: linked list (simple)
Analyze 5 indicators of NFT project
Flex layout
flex布局
异或的应用。(提取出数字中最右侧的1,面试中经常用的到)
Kubelet garbage collection (exiting containers and unused images) source code analysis
Jetpack - defects of livedata component and Countermeasures
卸载重装最新版mysql数据库亲测有效
Redis implements distributed locks
HJ字符个数统计
Implementation of commit message standardized control in large projects
Design and implementation of spark offline development framework
[thanos source code analysis series]thanos query component source code analysis
大型项目中的Commit Message规范化控制实现
HJ进制转换
Leetcode+ 51 - 55 retrospective and dynamic planning topics