MCPcopy Create free account
hub / github.com/google/adk-python / check_prime

Function check_prime

contributing/samples/core/hello_world/agent.py:39–64  ·  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

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

Callers

nothing calls this directly

Calls 3

setFunction · 0.85
addMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected