A couple of days ago I made a "combinations" function in #C that works the same as #Python itertools.combinations. I used it to help with a #Numberphile challenge, however I misunderstood: duplicates WERE allowed. So I binned it all, went back to nested loops and added multi-threading. Now it only takes about 0.01 s to calculate all #tetrahedral sums (up to 5 terms) of 343867 which is supposed to be the last one that requires more than 4 terms.
Works on #Mac and #Linux: https://github.com/ednl/tetrahedral/blob/main/tetrasum.c

tetrahedral/tetrasum.c at main · ednl/tetrahedral
Pollock's conjecture: any integer can be written as a sum of at most five tetrahedral numbers. - ednl/tetrahedral
GitHub… or other numbers! The program is not specifically geared towards confirming or disproving the conjecture, but it can analyse every number between 0 and 2^32. Just add the number on the command line: e.g. "tetrasum -q 10000001" outputs 92 sums of tetrahedral numbers with up to four terms and counts another 5592 sums with five terms.
It took a little under 3 hours for my program on a #RaspberryPi 5 with 4 cores at 2.4 GHz to calculate that there are 863 #tetrahedral sums of up to 4 terms for the number 2^32-1, and another 377968 sums of 5 terms.
#programming #C #Clanguage #C_lang #mathematics #maths #math #numberphile #JournalOfRecreationalMathematics #compsci #PollocksConjecture