# doctest: +NORMALIZE_WHITESPACE This functions takes a list of prime factors as input. returns True if the factors are square free. >>> is_square_free([1, 1, 2, 3, 4]) False These are wrong but should return some value it simply checks for repetition in the num
(factors: list[int])
| 8 | |
| 9 | |
| 10 | def is_square_free(factors: list[int]) -> bool: |
| 11 | """ |
| 12 | # doctest: +NORMALIZE_WHITESPACE |
| 13 | This functions takes a list of prime factors as input. |
| 14 | returns True if the factors are square free. |
| 15 | >>> is_square_free([1, 1, 2, 3, 4]) |
| 16 | False |
| 17 | |
| 18 | These are wrong but should return some value |
| 19 | it simply checks for repetition in the numbers. |
| 20 | >>> is_square_free([1, 3, 4, 'sd', 0.0]) |
| 21 | True |
| 22 | |
| 23 | >>> is_square_free([1, 0.5, 2, 0.0]) |
| 24 | True |
| 25 | >>> is_square_free([1, 2, 2, 5]) |
| 26 | False |
| 27 | >>> is_square_free('asd') |
| 28 | True |
| 29 | >>> is_square_free(24) |
| 30 | Traceback (most recent call last): |
| 31 | ... |
| 32 | TypeError: 'int' object is not iterable |
| 33 | """ |
| 34 | return len(set(factors)) == len(factors) |
| 35 | |
| 36 | |
| 37 | if __name__ == "__main__": |