1-100所有没有平方因数的 d:
[1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 46, 47, 51, 53, 55, 57, 58, 59, 61, 62, 65, 66, 67, 69, 70, 71, 73, 74, 77, 78, 79, 82, 83, 85, 86, 87, 89, 91, 93, 94, 95, 97]
- # Define a function to check if a number is square-free
- def is_square_free(n):
- # Factorize the number into prime powers
- factors = factor(n)
- # Check if any of the prime powers has an exponent greater than 1
- for p, e in factors:
- if e > 1:
- return False
- # If none of the prime powers has an exponent greater than 1, the number is square-free
- return True
- # Create an empty list to store the square-free integers
- square_free = []
- # Loop through the numbers from 1 to 100
- for n in range(1, 101):
- # Check if the number is square-free and add it to the list if it is
- if is_square_free(n):
- square_free.append(n)
- # Print the list of square-free integers
- print(square_free)
Copy the Code 如何从这个列表中过滤掉满足唯一分解条件的d? |