-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patha010.py
More file actions
61 lines (56 loc) · 1.31 KB
/
a010.py
File metadata and controls
61 lines (56 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 31 21:20:07 2019
@author: sam0225
"""
# def m(n):
# sl = []
# while n > 1:
# for i in range(2, n + 1):
# if n % i == 0:
# sl.append(i)
# n = int(n / i)
# break
#
# s = str(sl[0])
# if sl.count(sl[0]) > 1:
# s += '^' + str(sl.count(sl[0]))
#
# for i in range(1, len(sl)):
# if sl[i] != sl[i - 1]:
# t = sl.count(sl[i])
# if t > 1:
# s += " * " + str(sl[i]) + "^" + str(t)
# else:
# s += " * " + str(sl[i])
#
# print(s)
#
#
# while True:
# try:
# m(int(input()))
# except:
# break
while True:
try:
_input = int(input())
factorsCount = 0
factor = 2
s = ''
while _input > 1:
while _input % factor == 0:
_input = _input // factor
factorsCount += 1
if factorsCount > 1:
s += str(factor) + '^' + str(factorsCount)
if factorsCount == 1:
s += str(factor)
if _input % (factor + 1) == 0 and s != '':
s += ' * '
factorsCount = 0
factor += 1
print(s)
except:
break