Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Goldbach's conjecture #11131

Closed
wants to merge 8 commits into from
44 changes: 44 additions & 0 deletions maths/Goldbach's conjecture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'''
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):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: isprime. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function isprime

Please provide type hint for the parameter: num

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: isprime. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function isprime

Please provide type hint for the parameter: num

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: isprime. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function isprime

Please provide type hint for the parameter: num

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: isprime. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function isprime

Please provide type hint for the parameter: num

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: isprime. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function isprime

Please provide type hint for the parameter: 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==True:

Check failure on line 17 in maths/Goldbach's conjecture.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E712)

maths/Goldbach's conjecture.py:17:19: E712 Comparison to `True` should be `cond is True` or `if cond:`
return False
else:
return True

Check failure on line 20 in maths/Goldbach's conjecture.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (SIM103)

maths/Goldbach's conjecture.py:17:9: SIM103 Return the condition `value == True` directly


def istrue(x):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: istrue. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function istrue

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: istrue. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function istrue

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: istrue. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function istrue

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: istrue. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function istrue

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: istrue. If the function does not return a value, please provide the type hint as: def function() -> None:

As there is no test file in this pull request nor any test function or class in the file maths/Goldbach's conjecture.py, please provide doctest for the function istrue

Please provide type hint for the parameter: x

Please provide descriptive name for the parameter: 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("-->"))
test_num=4
A=[]
B=[]
while test_num <= final_num:
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")
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")