def find_factors(n): factors = [] for i in range(1, n + 1): if n % i == 0: factors.append(i) return factors # 例如,用python求出整数 1024 的因数 print(find_factors(1024)) #[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]