aboutsummaryrefslogtreecommitdiff
path: root/challenge-198/robert-dicicco/python/ch-2.py
blob: 71d5718b18236fe5534c61909c2fb869166c6cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python

'''

AUTHOR: Robert DiCicco

DATE  : 2023-01-02

Challenge 198 Prime Count ( Python )

'''

 

arr = [10,15,1,25]

 

def isprime(num):

    if num > 1: 

        for n in range(2,num): 

            if (num % n) == 0: 

                return False

        return True

    else:

        return False

 

for n in arr:

    cnt = 0

    print(f"Input: $n = {n}")

    for x in range(n):

        if isprime(x):

            #rint(x)

            cnt += 1

    print(f"Output: {cnt}\n")

   

'''

python .\PrimeCount.py

Input: $n = 10

Output: 4

 

Input: $n = 15

Output: 6

 

Input: $n = 1

Output: 0

 

Input: $n = 25

Output: 9

'''