aboutsummaryrefslogtreecommitdiff
path: root/challenge-150/abigail/python/ch-2.py
blob: c1fd1e5447f37dbb73c44c521b1eb26b7b124a23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/local/bin/python3

#
# See https://theweeklychallenge.org/blog/perl-weekly-challenge-150
#

#
# Run as: python ch-2.py
#

import sys

primes = [2, 3, 5, 7, 11, 13, 17, 19]

for n in range (1, 501):
    has_square = False
    for p in primes:
        if n % (p * p) == 0:
            has_square = True
    if not has_square:
        sys . stdout . write (str (n) + " ")
sys . stdout . write ("\n")