Skip to content

Commit b63a111

Browse files
Kaiyotoharshildarji
authored andcommitted
Added a new Algorithm to check if a number is prime or not. (#487)
* Added a new Algorithm to check if a number is prime or not. Added a new Algorithm to check if a number is prime or not. It takes one + half the amount of iterations of the square root of the number. Returns Boolean value. * Fixed possibility of being truncated Changed the 1/2 with a 0.5 * Fixed Major Error Instead of 3, 5, 7 The Loop as checking 2, 4, 6 which would cause all odd numbers to show prime. Fixed by subtracting one. * Fixed Minor Formatting issues Github Merged the 2 previous and current version to make a weird file. * Fixed possibility of being truncated Changed the 1/2 with a 0.5
1 parent 116ab0f commit b63a111

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Maths/PrimeCheck.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def primeCheck(number):
2+
prime = True
3+
for i in range(2, int(number**(0.5)+1), 2):
4+
if i != 2:
5+
i = i - 1
6+
if number % i == 0:
7+
prime = False
8+
break
9+
return prime
10+
11+
def main():
12+
print(primeCheck(37))
13+
print(primeCheck(100))
14+
print(primeCheck(77))
15+
16+
if __name__ == '__main__':
17+
main()

0 commit comments

Comments
 (0)