login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A138244
a(1)=1; for n>1, a(n) = smallest integer > a(n-1) such that a(n) is coprime to (a(k) - a(k-1)) for all k, 2 <= k <= n and such that (a(n) - a(n-1)) doesn't equal (a(k) - a(k-1)) for any k, 2 <= k <= n-1.
3
1, 2, 5, 7, 11, 17, 25, 37, 47, 61, 79, 101, 127, 151, 167, 197, 229, 257, 277, 311, 347, 389, 433, 479, 541, 593, 631, 691, 739, 797, 853, 907, 947, 997, 1061, 1129, 1201, 1277, 1361, 1427, 1517, 1597, 1667, 1741, 1823, 1901, 1987, 2081, 2179, 2267, 2371
OFFSET
1,2
COMMENTS
a(n+1) - a(n) = A138245(n).
LINKS
Michel Marcus, Table of n, a(n) for n = 1..10000 (terms 1..1000 from Joshua Zucker, Mar 09 2008)
MATHEMATICA
a[1] = 1; a[n_] := a[n] = Module[{m = a[n - 1] + 1}, While[MemberQ[(t = Table[a[k] - a[k - 1], {k, 2, n - 1}]), m - a[n - 1]] || ! CoprimeQ[m, m - a[n - 1]] || !AllTrue[t, CoprimeQ[m, #] &], m++]; m]; Array[a, 50] (* Amiram Eldar, Nov 16 2021 *)
PROG
(PARI) isok(dlist, last, k) = {if (gcd(k, k-last) != 1, return (0)); for (i=1, #dlist, if (gcd(k, dlist[i]) != 1, return(0)); if ((k-last) == dlist[i], return(0)); ); return(1); }
findnext(dlist, last, n) = {my(k=last+1); while (!isok(dlist, last, k), k++); k; }
lista(nn) = {my(list=List(), dlist=List()); listput(list, 1); for (n=2, nn, my(x=findnext(dlist, list[n-1], n)); listput(dlist, x-list[n-1]); listput(list, x); ); Vec(list); } \\ Michel Marcus, Nov 16 2021
(Python)
from math import gcd
from itertools import count, islice
def agen(): # generator of terms
yield from [1, 2]
anm1, an, diffs, mind = 1, 2, {1}, 2
while True:
anm1, an = an, max(an+1, mind)
while an-anm1 in diffs or gcd(an, an-anm1) != 1 or any(gcd(an, dk) != 1 for dk in diffs):
an += 1
diffs.add(an - anm1)
while mind in diffs: mind += 1
yield an
print(list(islice(agen(), 51))) # Michael S. Branicky, Jan 28 2023
CROSSREFS
Cf. A138245.
Sequence in context: A062044 A077128 A106008 * A326505 A019396 A153767
KEYWORD
nonn
AUTHOR
Leroy Quet, Mar 08 2008
EXTENSIONS
More terms from Joshua Zucker, Mar 09 2008
STATUS
approved