MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / is_square_free

Function is_square_free

maths/is_square_free.py:10–34  ·  view source on GitHub ↗

# 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])

Source from the content-addressed store, hash-verified

8
9
10def 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
37if __name__ == "__main__":

Callers 1

mobiusFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected