Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def factorization(n):
- p = []
- d = 2
- while d * d <= n:
- cnt = 0
- while n % d == 0:
- cnt += 1
- n //= d
- if cnt != 0:
- p.append([d, cnt])
- d += 1
- if n > 1:
- p.append([n, 1])
- return p
- def print_summand(summand):
- prime, degree = summand
- if degree > 1:
- return '{}^{}'.format(prime, degree)
- return str(prime)
- print('*'.join(map(print_summand, factorization(int(input())))))
Advertisement
Add Comment
Please, Sign In to add comment