Skip to content

Commit 887c461

Browse files
imo-252RiceViztxjackson252Trinitie Jacksonbscott519
authored
feat: adds Martha's prime number checker (#184)
* feat: define criteria for coding assignment * feat: adds Tyrans quiz to the quizzes folder with correct bcrypt hashing (#105) * feat: adds lesson_03 trinitiejackson quiz (#108) * trinitie_jackson_quiz * change closed to void * change tag to element * change question and answers * add anthony_mays_quiz back * edit spacing --------- Co-authored-by: Trinitie Jackson <[email protected]> * feat: adds Benjamin's completed lesson 03 hw (#107) * feat: adds Danielson Adjocy's lesson_03 quiz (#111) * Added files * update * update * update * update * update * update * update * ”update” * finished README * fix:fixing chhange requests * feat: add work email * feat: added test and passing * chore:updating * Update quiz.yaml * Update quiz.yaml * revert: reverted another_quiz.ts * Update quiz.yaml * fix: quizzes.module.ts --------- Co-authored-by: Danielson Adjocy <[email protected]> * feat: adds lesson_05 quiz (#151) Signed-off-by: Anthony D. Mays <[email protected]> * feat: added quiz check (#170) Signed-off-by: Anthony D. Mays <[email protected]> * feat: adds lesson_05 homework and lesson_06 pre-work (#171) Signed-off-by: Anthony D. Mays <[email protected]> * docs: fix bug with assignment details (#179) Signed-off-by: Anthony D. Mays <[email protected]> * feat: add criteria doc to martha's lesson 04 homework file * feat: create python code file * chore: update doc name to README * feat: add python prime checking function to file * feat: create JavaScript code file * chore: adds semicolons to clean up formatting * feat: add writeup for Martha's lesson_04 homework --------- Signed-off-by: Anthony D. Mays <[email protected]> Co-authored-by: Tyran Rice Jr. <[email protected]> Co-authored-by: txjackson252 <[email protected]> Co-authored-by: Trinitie Jackson <[email protected]> Co-authored-by: bscott519 <[email protected]> Co-authored-by: Danielson A. <[email protected]> Co-authored-by: Danielson Adjocy <[email protected]> Co-authored-by: Anthony D. Mays <[email protected]>
1 parent b0fddbc commit 887c461

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

lesson_04/marthao/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Explanation
2+
3+
The languages used for the assignment are Python and JavaScript. In order to determine whether or not a number is prime, the functions used for both the Python implementation and the JavaScript implementation needed to meet the following criteria:
4+
5+
- If the number is less than 2, it is not prime.
6+
- If the number is 2, it is prime.
7+
- If the number can be evenly divided by 2 (i.e. the remainder of the division of the number by 2 equals 0), it is not prime.
8+
- If the number is greater than 2 and can be evenly divided by any number from 2 up to the square root of the number, it is not prime.
9+
- If the number can NOT be evenly divided by any number from 2 up to the square root of the number, it is prime.
10+
11+
### Other Similarities
12+
- In both Python and JavaScript, `i` is used to represent the numbers being tested as divisors.
13+
14+
### Differences
15+
- #### Syntax:
16+
- In Python, the function is defined using the `def` keyword, while the `function` keyword is used in JavaScript.
17+
- In Python, the `==` is used as the equality operator, while `===` is used as the equality operator in JavaScript.
18+
- In Python the `True` and `False` are used for boolean values, while JavaScript uses `true` and `false`.
19+
- In Python the equation for square root is represented by `n**0.5`, while Python represents it by `Math.sqrt(n)`.
20+
21+
22+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function checkIfPrime(n) {
2+
if (n < 2) {
3+
return false;
4+
}
5+
if (n === 2) {
6+
return true;
7+
}
8+
if (n % 2 === 0) {
9+
return false;
10+
}
11+
for (let i=3; i <=Math.sqrt(n) + 1; i = i + 2) {
12+
if (n % i === 0) {
13+
return false;
14+
}
15+
}
16+
return true;
17+
}

lesson_04/marthao/pythoncode.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def is_prime(n):
2+
if n < 2:
3+
return False
4+
5+
if n == 2:
6+
return True
7+
8+
if n % 2 == 0:
9+
return False
10+
11+
for i in range(3, int(n**0.5) + 1, 2):
12+
if n % i == 0:
13+
return False
14+
15+
return True

0 commit comments

Comments
 (0)