Interview Questions

Python - List Prime Numbers

Use the following Python script to list Prime numbers in a given range.

#!/usr/bin/env python3

for n in range(2, 1000):
    h = int(n / 2);
    for x in range(2, h):
        if n % x == 0:
            print (n, 'equals', x, '*', n / x)
            break
    else:
        print (n , 'is a prime number')