Stuck on the 'is_prime' class


Hi All,

I am stuck at the ‘is_prime’ class under ‘Practice Makes Perfect’.

I receive no error messages, nothing seems to happen with I run this program

The function should be evaluated with candidate prime numbers, here is the code, what am
I doing wrong? Noting happens when I run this program.

def is_prime(x):
  if x < 2:
    return False
    n = 2
    while n <= (x - 1):
      if x % n == 0:
        return False 
      return True


I think I see the problem… i’m not incrementing ‘n’… causing an infinite loop condition…



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.