David Sycamore

45 Reputation

4 Badges

1 years, 190 days

MaplePrimes Activity

These are replies submitted by David Sycamore

@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 ?


@Carl Love Hi Carl,

Thank you for your very comprehensive response to my question, I hope you found it as interesting to do as I did to receive. I agree your analysis of the zeroes above,and was pleasantly surprised to see that you had extended the work to include numbers whose smallest prime divisor >3, something I had not anticipated.  

Best wishes


@tomleslie Hi Tom, My Maple issue is 2017. Thanks for resending me the code. I followed your instructions and  was not asked about the application. I downloaded it directly to a Maple worksheet and tried to run it from the point you indicated. It did not work and returned the error message:

    "Error, (in CodeTools:-Usage) unable to execute seq". 

I am very grateful for all your assistance here, and all the insights and suggestions provided by Carl, which i have understood. In fact I had reached the same conclusion about proving the zeroes using congruences, eg since (3,5,7) correspond to (0,1,2) (mod 3), namely every equivalence class (mod 3) is there, then it follows that adding even k to all of them will result in one of those numbers being divisible by 3. Therefore any number which included 3,5 and 7 amongst its prime factors will always return a provable zero.The same approach works for all the other starting ponts I have tried ((3,5,13),(3,11,13), (3,7,23) and so on. However what I had not expected was to find zeroes for cases when the smallest prime is not 3 but 5,7,....., 37). This is new and very interesting and I had no trouble getting his code to run. As for running this one, maybe the eror message will enable you to understand why this happened, if so please let me know. Finally I am not familiar with all details of your code, example what does +~e mean ? If you know of a good textbook on Maple please let me know, my interest is mainly number theory as you can see. 

Best wishes



Hi Tom,

Thanks for this quick response. I am very interested in your results, had already seen the prime factor 3 thing and think perhaps it could be explained somehow (I don’t think it’s coincidence).  First I want to run the code for myself, get the data out and check with my hand cranking results then do some analysis. First problem is getting it to run. I am a novice with Maple so need the guide for dummies. Can you tell me what Instructions I need to add to your code to get it to run? Do I have to call the proc somehow? At the moment what I have done is copy your code (down to the end of the doWork proc ) into a worksheet and hit return. Then what I get is “unable to parse” . Obviously I am doing something wrong here. 


Questions: You define Nodd and Neven but they never seem to be called later in the script. However the doWork proc includes “N” , which N is this? I don’t follow, sorry. 



Many thanks for the response. Please advise how to modify the code so as to identify odd squarefree numbers n having more than 2 prime factors and the property p-1|n-1 only for the least and greatest prime divisors p of n. I have tried without success to do this myself. Assistance much appreciated.



@vv Would it be possible to modify the previous code so as to output odd squarefree composite numbers having at least 3 prime divisors and the property that the only prime divisors p such that p-1|n-1 are the smallest and the greatest prime factors of n? 

The (provisional) data I have so far is: 231,1045, 1653, 4371, 4641, 5365, 6545, 8029, 9361, 10011, 10857

Best Regards

David Sycamore.



@Carl Love 

Regarding your comment about the squarefree function not being a check for squarefree but for returning the squarefree factorisation, I find this not to be quite the case.

Using with(NumberTheory) I find that IsSquareFree(n) returns the correct answer. Perhaps the capitalisation calls a different version?

Any comment?

@Carl Love Thanks,

By the way I found a way to compute all conforming terms up to an arbitrary N, just put your proc into a do loop; easier than I expected. 

1 2 3 Page 1 of 3