MCPcopy
hub / github.com/google/adk-python / check_prime

Function check_prime

contributing/samples/tools/tool_functions_config/tools.py:37–62  ·  view source on GitHub ↗

Check if a given list of numbers are prime. Args: nums: The list of numbers to check. Returns: A str indicating which number is prime.

(nums: list[int])

Source from the content-addressed store, hash-verified

35
36
37async def check_prime(nums: list[int]) -> str:
38 """Check if a given list of numbers are prime.
39
40 Args:
41 nums: The list of numbers to check.
42
43 Returns:
44 A str indicating which number is prime.
45 """
46 primes = set()
47 for number in nums:
48 number = int(number)
49 if number <= 1:
50 continue
51 is_prime = True
52 for i in range(2, int(number**0.5) + 1):
53 if number % i == 0:
54 is_prime = False
55 break
56 if is_prime:
57 primes.add(number)
58 return (
59 'No prime numbers found.'
60 if not primes
61 else f"{', '.join(str(num) for num in primes)} are prime numbers."
62 )

Callers

nothing calls this directly

Calls 3

setFunction · 0.85
addMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected