aboutsummaryrefslogtreecommitdiff
path: root/challenge-198/robert-dicicco/python
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2023-01-02 21:03:27 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2023-01-02 21:03:27 +0000
commit79335458f4f82deed9d4caca0f563fd7adfbb276 (patch)
tree9f22b050ef42f61cdef338bd3d4ff455f71e5128 /challenge-198/robert-dicicco/python
parent00cc4d779f1fdbdd6a22b1c029f2fbdc857ff132 (diff)
downloadperlweeklychallenge-club-79335458f4f82deed9d4caca0f563fd7adfbb276.tar.gz
perlweeklychallenge-club-79335458f4f82deed9d4caca0f563fd7adfbb276.tar.bz2
perlweeklychallenge-club-79335458f4f82deed9d4caca0f563fd7adfbb276.zip
- Added solutions by Robert DiCicco.
Diffstat (limited to 'challenge-198/robert-dicicco/python')
-rw-r--r--challenge-198/robert-dicicco/python/ch-2.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/challenge-198/robert-dicicco/python/ch-2.py b/challenge-198/robert-dicicco/python/ch-2.py
new file mode 100644
index 0000000000..71d5718b18
--- /dev/null
+++ b/challenge-198/robert-dicicco/python/ch-2.py
@@ -0,0 +1,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
+
+'''