David Sycamore

95 Reputation

4 Badges

6 years, 12 days

MaplePrimes Activity

These are replies submitted by David Sycamore


I got it running, have now ~50 terms which is great. I would now like to examine for each number n in the sequence the set P(n) of partition primes of n. Is it possible to adapt the code for this purpose?

Thanks in advance



Just checking how to do this: Copy paste code from the outline box above into a new worksheet, do changes for 2017, and then add :

for n from 2 to N do 

if........ fi


Then run

Is that right?


@David Sycamore 

Will it work in 2017?


Thanks very much for this; great job! I will try to run it later today (with Maple 2017).


@Carl Love Thanks for the clarification. I wrote {phi} because there was no way to write the usual Greek letter. What I meant was of course the empty set {}, not the set containing the empty set as sole element. 

@David Sycamore 

I wonder if it could be possible to argue (using the Goldbach conjecture) that for an even number 2n we will always be able to find a p in P(2n) such that 2n-p is a prime q>p such that p is not a member of P(q). Then p+q=2n and this is the only partition of 2n having p as least part.  Ergo in the set of partitions of 2n we will always find a (p,1), which if correct means that the numbers I am looking for are all odd composites (like 63,161...), no need to look for primes or even numbers. 

@Kitonum Yes I mean that {phi} is empty set and I thought that notation was universal, just that I have no way to write it as it appears in text books.



1. No restriction on the number of summands or the starting (least) prime which I call a "partition prime" of n (my own terminology, it might be called by another name elsewhere). 

2. Yes this is about partition of any whole number n into primes, so all the  summands are primes and they don't have to be distinct.

3. Let P(n) be the set of partition primes of n, so for n=12, P(12)={2,3,5}. Any prime partition of 12 must have one of these numbers as least part. Q(n) is a subset of P(n) and lists the "singular partition primes of n", meaning those which appear (as least part) in one and only one partition of n into primes. So Q(12)={3,5} because 3+3+3+3 = 5+7 = 12 are the only possible choices having least part 3 and 5 respectively.

I have a recursive method for computing the overall number of partitions of n into primes by adding up the number of partitions with least part p, for every p in P(n). This works but is laborious and I don't know how to tackle a code for it, which is why I sought assistance on here. 

4. The strange thing about 63 is that it has no singular partition prime. Compare the following: 46 is chosen at random:

P(46)= {2,3,5,7,11,17,23}, and the associated partition numbers are: (2,456), (3, 77), (5, 17), (7, 4), (11,1),  (17,1), (23,1), where (p,m) means there are m partitions (of 46) having least part p. Thus Q(46)={11,17,23}. However P(63)={2,3,5,7,11,13,17}, for which the corresponding partition numbers (for all p in P(63)) are: (2,2198), (3,323), (5,60), (7,15), (11,5), (13,2), (17,2). Since there is no (p,1) in this collection, Q(63)={phi}, the empty set. I thought that this was a one-off anomaly number because no ´n<63 has this property, but then found that 161 has the same property. P(161)={2,3...47} and the partition numbers are (2,1305679), (3,124055), (5,15646), (7,3006), (11,687), (13,236), (17,85), (19,38), (23,16) (29,9), (31,4), (37,2), (41,4), (43,2), and (47,2). There is no (p,1) in this set so Q(161)={phi}. My calculations have now reached 167 and these are the only two numbers having this property, which is why I am curious to know if there are any more. 

I hope this clarifies my question and that you can help with a code. 



ps: Carl please say what was wrong with my use of {phi}?

@tomleslie Thanks Tom. I guess because I have a different Maple version from yours (2017), my system copied your code reluctantly (warning it might not work), which it did'nt ("unable to execute seq"). Did we not have this problem last time?

 I copied it out by hand into a new worksheet and tried again. This time ("local f is declared more than once in procedure doWork"). I had ben wondering about this (f twice) thing before, and  assumed its something ok for your version but maybe not mine (?). The second line of code says "interface(version)" am I supposed to put the version there, or does it mean something else? Sorry so many questions, none of this is "trivial" for me. 

@David Sycamore Sorry to come back again on this code. For oeis I would aappreciate to have a version of the code which just outputs the numbers a(n), for n up to arbitrary N (no factor sets, just single numbers including the zeroes where there are no solutions up to some M). I have tried to extract this from your code by just taking out the doWork proc, but cannot get it to work. Hope you wont mind to show me how to do this. (code will of course be attributed in oeis entry).


@Carl Love Yes of course; its obvious that containing itself as a proper subsequence means it contains  infinitely many copies of itself. However, I was thinking in terms of  independent copies (indeed it is powers of 4, not 2, but maybe should be q>0?). So there are infinitely many independent copies, each of which contains infinitely many copies ......... Right?

@Carl Love Great work, thanks.

Seems that the sequence may contain infinitely many copies of itself. Your find a(4*q+2) for a 4-spaced subsequence can be generalised to a(2^n*q+2^n-2) for a 2^n-spaced subsequence (n>=2). Would you agree?

@Carl Love 0 1 2 3  4     (indices)

                    0,0,0,1, 0     (terms)

Here the initial (given) terms are a(0)=0, a(1)=0 (see above, indices written over terms; terms separated by commas, indices not). We have a(0) and a(1) and want to find the next term, a(2), so we ask here: Have we seen this (most recent) number (which is a(1)=0 ) prior to this occurrence of it? And if so what was its position (index)? Answer is yes and we saw it before as the 0-th term, (its index was 0), so now we have a(2)=0. (we can now imagine "marking" that index, to show that it has been used, so we dont use it again). Now we want a(3): Have we seen this number (which is a(2)=0) before? Yes, it is a 0 and the nearest, most recent, "unmarked" place it was seen was at a(1)=0, whose index was 1, so a(3)=1. Now for a(4): Have we seen this number (which is a(3)=1) before? Answer is no, so we follow the rule: a(n+1)=a(a(n)-1), getting a(4)=a(a(3)-1)=a(1-1)=a(0)=0; therefore a(4)=0. And so on....

( "Last" means the most recent unmarked occurrence)



That's cool Carl, thanks. Now here's the one I was really after, just wanted to know how to keep and compare terms. I doubt a formula would  work here but would like to be proved wrong:

a(0)=a(1)=0. a(n+1) = index of the last term k = a(n), if that value has appeared before; else a(n+1) = a(a(n)-1).

0,0,0,1,0,2,0,4,1,3,0,6,2,5,0,10,3,9,1,8,4,7,0......    Terms and indices read backwards between any pair of 0s generate the forward string of terms between the next but one pair of 0s.

Recursive, self generating self referencing sequence. 

Terms enter the sequence first as indices of previous terms (see rule); Subsequence: 0,1,2,4,3,6,5,10..... the one you already know.
Then they re enter, repeatedly; (see rule); Subsequence: 0,0,1,0,2,0,3,1,1,4,0..... By prepending a zero to this, and rotating terms betwen 0s, the original sequence re appears........  


Tom, Thank you, it works fine and I have all the output I need. You and Carl did a great job. I hope you wont mind to explain one small detail of your code. I dont see how "N" works in your script (though obviously it does). Nodd and Neven are defined upfront, and called elsewhere, but N is nowhere mentioned prior to or after its use in the doWork proc.

I can confirm that my Maple version is indeed 2017, (at least thats what it says on the tin),



@Carl Love Thanks for the counter example; nice work. I tried to find another one of the same form: 

P=[p_1,p_2,....p_k], all p_i the lesser  of twin prime pairs, where k = p_2, and I looked for congruences modulo p_2, hoping to find every one of  {0,1,...p_2 -1} present, as is the case for [2,3,5] (mod 3), and [3,5,11,17,29] (mod 5). 

In the case of (mod 11) and (mod 17), looking at 11 and 17 primes respectively I could find no lesser twin prime q< 11,17 such that q== 9,15 respectively. I wonder if this always happens, ie no solution to q==p_2 - 2, where p_2 is the second in the list P of p_2 lesser twin primes P=[p_1,p_2,...p_k]; k=p_2 ? 

If this is true there are no more examples like the one you found, so any other counter example would have to look different in form; maybe Cousin primes? 

I found [3,7,13,19,37,43,67], with all congruences (mod 7) present and just one non zero solution (k=4), analogous to what you found for twin primes. 

If the same holds true for higher prime gaps: 6,8,... then there might be infinitely many counter examples. Any comment ?


1 2 3 4 5 6 Page 3 of 6