# [seqfan] Re: I need help with defining these 3 sequences

M. F. Hasler seqfan at hasler.fr
Sun Mar 1 22:11:04 CET 2020

```On Sun, Mar 1, 2020 at 2:30 AM Ali Sada wrote:

> Sequence 3:    I have a definition for this sequence, but I am sure it
> could be improved.
> The definition is “a(1) =1; a(n) is the lexicography earliest positive
> integer such that n+1 and the summation of terms up to a(n) are co-primes.”
>

Simpler and correct:
a(n) is the *least* positive integer *not used earlier* such that n+1
and the *sum* of terms up to a(n) are co-primes.
(You don't need "lexicograph(icall)y", but below it is clarified that you
don't want repetitions.)

> To find a(2), we need the earliest positive integer such that a(1) + a(2)
> is co-prime with 3. So, a(2) = 3. To find a(3), we cannot put neither 2 nor
> 4, because 6 and 8 have a common factor with 4, so we put a(3) = 5.

but we could put a(3)=3 if this wasn't forbidden, since 1+3+3 = 7 is
coprime with 4.

The sequence we get is:
> 1, 3, 5, 2, 6, 7, 9, 4, 10, 11, 13, 8, 14, 16, 12, 17, 19, 15, 21, 18, 22,
> 23, 25, 20, 26, 28, 24, 29, 31, 27, 33, 30, 34, 35, 37
>

yes, confirmed by
(PARI) /* s & u = sum & bitmap of terms used so far */
for(n=2,#a=Vec(u=s=1,100), u+=1<<a[n-1]; for(k=valuation(u+1,2),oo,
bittest(u,k) || gcd(s+k,n+1)>1 || [s+=a[n]=k,break]));a

--
Maximilian

```