1、python2
from __future__ import print_function num = int(raw_input()) i = 2 while num != 1: while num % i == 0: print(i, end=‘ ‘) num /= i i += 1
2、python3
import sys num = int(sys.stdin.readline()) i = 2 while num != 1: while num % i == 0: print(i, end=‘ ‘) num /= i i += 1
原文:http://www.cnblogs.com/llw1121/p/7616407.html