From 69b324dfc17c4295ce3bc5add0f8ba970c453573 Mon Sep 17 00:00:00 2001 From: Amritanshu Barpanda <145291762+ABarpanda@users.noreply.github.com> Date: Tue, 31 Oct 2023 23:30:52 +0530 Subject: [PATCH 1/6] Added Goldbach's conjecture --- maths/Goldbach's conjecture.py | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 maths/Goldbach's conjecture.py diff --git a/maths/Goldbach's conjecture.py b/maths/Goldbach's conjecture.py new file mode 100644 index 000000000000..98b2318bf0e2 --- /dev/null +++ b/maths/Goldbach's conjecture.py @@ -0,0 +1,40 @@ +''' +This program will search every even number less than the inputted number and then show which numbers passed the test and which didn't. +''' + +def isprime(num): + value = False + + if num == 1: + #print(num, "is not a prime number") + pass + elif num > 1: + for i in range(2, num): + if (num % i) == 0: + value = True + break + if value: + return False + else: + return True +def istrue(x): + t=0 + while t<= x/2: + if isprime(t) == 1 and isprime(x-t) == 1: + return True + t=t+1 + +final_num=int(input("-->")) +x=4 +A=[] +B=[] +while x <= final_num: + if istrue(x)== 1: + #print(x,"follows Goldbach's conjecture") + A.append(x) + else: + print(x,"does not follow the Goldbach's conjecture") + B.append(x) + x=x+2 +print(A, "follow the Goldbach's conjecture") +print(B, " does not follow the Goldbach's conjecture") From f3503f1f3f79a26c6b2e35c5661f16fc5003afcf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:07:45 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/Goldbach's conjecture.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/maths/Goldbach's conjecture.py b/maths/Goldbach's conjecture.py index 98b2318bf0e2..803ac30d7aba 100644 --- a/maths/Goldbach's conjecture.py +++ b/maths/Goldbach's conjecture.py @@ -1,12 +1,13 @@ -''' +""" This program will search every even number less than the inputted number and then show which numbers passed the test and which didn't. -''' +""" + def isprime(num): value = False if num == 1: - #print(num, "is not a prime number") + # print(num, "is not a prime number") pass elif num > 1: for i in range(2, num): @@ -17,24 +18,27 @@ def isprime(num): return False else: return True + + def istrue(x): - t=0 - while t<= x/2: - if isprime(t) == 1 and isprime(x-t) == 1: + t = 0 + while t <= x / 2: + if isprime(t) == 1 and isprime(x - t) == 1: return True - t=t+1 + t = t + 1 + -final_num=int(input("-->")) -x=4 -A=[] -B=[] +final_num = int(input("-->")) +x = 4 +A = [] +B = [] while x <= final_num: - if istrue(x)== 1: - #print(x,"follows Goldbach's conjecture") + if istrue(x) == 1: + # print(x,"follows Goldbach's conjecture") A.append(x) else: - print(x,"does not follow the Goldbach's conjecture") + print(x, "does not follow the Goldbach's conjecture") B.append(x) - x=x+2 + x = x + 2 print(A, "follow the Goldbach's conjecture") print(B, " does not follow the Goldbach's conjecture") From 493711b8cc2500484170eb8d544669e7c446d9f3 Mon Sep 17 00:00:00 2001 From: Amritanshu Barpanda <145291762+ABarpanda@users.noreply.github.com> Date: Wed, 1 Nov 2023 00:07:17 +0530 Subject: [PATCH 3/6] Test pass trial 1 --- maths/Goldbach's conjecture.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/maths/Goldbach's conjecture.py b/maths/Goldbach's conjecture.py index 98b2318bf0e2..3745a5f81e77 100644 --- a/maths/Goldbach's conjecture.py +++ b/maths/Goldbach's conjecture.py @@ -1,5 +1,6 @@ ''' -This program will search every even number less than the inputted number and then show which numbers passed the test and which didn't. +This program will search every even number less than the inputted number +and then show which numbers passed the test and which didn't. ''' def isprime(num): @@ -13,7 +14,7 @@ def isprime(num): if (num % i) == 0: value = True break - if value: + if value==True: return False else: return True @@ -25,16 +26,16 @@ def istrue(x): t=t+1 final_num=int(input("-->")) -x=4 +test_num=4 A=[] B=[] -while x <= final_num: - if istrue(x)== 1: - #print(x,"follows Goldbach's conjecture") - A.append(x) +while test_num <= final_num: + if istrue(test_num)== 1: + #print(test_num,"follows Goldbach's conjecture") + A.append(test_num) else: - print(x,"does not follow the Goldbach's conjecture") - B.append(x) - x=x+2 + print(test_num,"does not follow the Goldbach's conjecture") + B.append(test_num) + test_num=test_num+2 print(A, "follow the Goldbach's conjecture") print(B, " does not follow the Goldbach's conjecture") From c6587dd2ceedea6149a2e79ad87d0684a318d2fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:48:53 +0000 Subject: [PATCH 4/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/Goldbach's conjecture.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/maths/Goldbach's conjecture.py b/maths/Goldbach's conjecture.py index ca61df053229..229a1cf533c2 100644 --- a/maths/Goldbach's conjecture.py +++ b/maths/Goldbach's conjecture.py @@ -1,7 +1,8 @@ -''' +""" This program will search every even number less than the inputted number and then show which numbers passed the test and which didn't. -''' +""" + def isprime(num): value = False @@ -14,7 +15,7 @@ def isprime(num): if (num % i) == 0: value = True break - if value==True: + if value == True: return False else: return True @@ -28,17 +29,17 @@ def istrue(x): t = t + 1 -final_num=int(input("-->")) -test_num=4 -A=[] -B=[] +final_num = int(input("-->")) +test_num = 4 +A = [] +B = [] while test_num <= final_num: - if istrue(test_num)== 1: - #print(test_num,"follows Goldbach's conjecture") + if istrue(test_num) == 1: + # print(test_num,"follows Goldbach's conjecture") A.append(test_num) else: - print(test_num,"does not follow the Goldbach's conjecture") + print(test_num, "does not follow the Goldbach's conjecture") B.append(test_num) - test_num=test_num+2 + test_num = test_num + 2 print(A, "follow the Goldbach's conjecture") print(B, " does not follow the Goldbach's conjecture") From d51ecdee7317b51c6209506d00baf6e0b7fbffbc Mon Sep 17 00:00:00 2001 From: Amritanshu Barpanda <145291762+ABarpanda@users.noreply.github.com> Date: Wed, 1 Nov 2023 01:22:11 +0530 Subject: [PATCH 5/6] Test pass trial 2 --- maths/Goldbach's conjecture.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/maths/Goldbach's conjecture.py b/maths/Goldbach's conjecture.py index ca61df053229..8c37c0b916bf 100644 --- a/maths/Goldbach's conjecture.py +++ b/maths/Goldbach's conjecture.py @@ -7,26 +7,23 @@ def isprime(num): value = False if num == 1: - # print(num, "is not a prime number") + #print(num, "is not a prime number") pass elif num > 1: for i in range(2, num): if (num % i) == 0: value = True break - if value==True: + if value == True: return False else: return True - - def istrue(x): - t = 0 - while t <= x / 2: - if isprime(t) == 1 and isprime(x - t) == 1: + t=0 + while t<= x/2: + if isprime(t) == 1 and isprime(x-t) == 1: return True - t = t + 1 - + t=t+1 final_num=int(input("-->")) test_num=4 @@ -41,4 +38,4 @@ def istrue(x): B.append(test_num) test_num=test_num+2 print(A, "follow the Goldbach's conjecture") -print(B, " does not follow the Goldbach's conjecture") +print(B, "does not follow the Goldbach's conjecture") From 530a195d88c4ac6000640edcd4503b5c1e72e157 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 19:55:30 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/Goldbach's conjecture.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/maths/Goldbach's conjecture.py b/maths/Goldbach's conjecture.py index 4304ca9fbb51..e9052b8a5ba5 100644 --- a/maths/Goldbach's conjecture.py +++ b/maths/Goldbach's conjecture.py @@ -8,7 +8,7 @@ def isprime(num): value = False if num == 1: - #print(num, "is not a prime number") + # print(num, "is not a prime number") pass elif num > 1: for i in range(2, num): @@ -19,12 +19,15 @@ def isprime(num): return False else: return True + + def istrue(x): - t=0 - while t<= x/2: - if isprime(t) == 1 and isprime(x-t) == 1: + t = 0 + while t <= x / 2: + if isprime(t) == 1 and isprime(x - t) == 1: return True - t=t+1 + t = t + 1 + final_num = int(input("-->")) test_num = 4