Answer to Question #321231 in Python for raghu varan

Question #321231

write a program to find the first prime number in the given inputs


1
Expert's answer
2022-04-25T04:43:05-0400


"""Define a function wich check the given number is prime"""
def isPrime(num:int)->bool:
  if(num==1):
    return False
  i=2
  while i*i<=num:
    if num%i==0:
      return False
    i+=1
  return True
nums=list(map(int,input("Please input nummbers: ").split()))
for nm in nums:
  if isPrime(nm):
    print("The first prime number: "+str(nm))
    break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS