pta连续因子Python
时间: 2023-11-29 16:45:38 浏览: 99
code2_1081_1082_pta_1071_
以下是求解pta连续因子的Python代码:
```python
import math
n = int(input())
count = 0
maxcount = 0
start = 0
for i in range(2, int(math.sqrt(n))+1):
# 连续因子的最大数不会超过根号n
temp = n
count = 0
j = i
while temp % j == 0:
temp //= j
j += 1
count += 1
if count > maxcount:
maxcount = count
start = i
if maxcount == 0:
print(1)
print(n, end='')
else:
print(maxcount)
for i in range(maxcount):
print(start + i, end='')
if i != maxcount - 1:
print("*", end='')
```
阅读全文