Goldbach Conjecture Python in Jupyter (concat update)

Опубликовано: 04 Август 2026
на канале: Mathematical Adventures
302
3

to change the notebook theme (I did this to get a dark theme)

pip install jupyterthemes
!jt -l
!jt -t chesterish -T -N -kl

reload the notebook
if something is missing, like the toolbar, go to View, and toggle it.

///the code below has been updated January 21, 2023 to move away from the soon-to-be-deprecated append method by the concat method///

def goldbachrange(begin,end):
df = pd.DataFrame(columns=["pass", "number", "p", "q"])
pass_count = 1
for i in range(begin,end,2):
divided_1 = int(i/2)
divided_2 = int(i/2)
for j in range(divided_2,i,1):
if(sp.isprime(divided_1) == True and sp.isprime(divided_2) == True):
new_row = pd.Series({"pass": pass_count,"number": i,
"p": divided_1,"q": divided_2})
df = pd.concat([df, new_row.to_frame().T], ignore_index=True)
divided_1 = divided_1 - 1
divided_2 = divided_2 + 1
pass_count = pass_count + 1
pass_count = 1
return df

def goldbach(i):
df = pd.DataFrame(columns=["pass", "number", "p", "q", "writes"])
pass_count = 1
writes = 0
divided_1 = int(i/2)
divided_2 = int(i/2)
for j in range(divided_2,i,1):
if(sp.isprime(divided_1) == True and sp.isprime(divided_2) == True):
writes = writes + 1
new_row = pd.Series({"pass": pass_count,"number": i,"p":
divided_1,"q": divided_2, "writes":writes})
df = pd.concat([df, new_row.to_frame().T], ignore_index=True)
divided_1 = divided_1 - 1
divided_2 = divided_2 + 1
pass_count = pass_count + 1
pass_count = 1
writes = 0
return df

///////////////////
All of the chatbots videos can be found here:
   • ChatGPT plans  
If you can think of a better way to engage with chatbots for mathematics, please leave a comment!
These videos are on a tangent to the other content in this channel:
Playlist for Math Books Read or Collected here:
   • 02 Books I am using for 2021-2022