login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A260940 a(n) is the smallest index j>n such that g(j)=0 for the sequence g defined (for indices > n) by g(n+1)=n and g(i) = g(i-1) - gcd(i,g(i-1)). 1
3, 5, 7, 7, 11, 13, 13, 17, 19, 19, 23, 19, 21, 29, 31, 31, 31, 37, 37, 41, 43, 43, 47, 43, 43, 53, 43, 41, 59, 61, 61, 61, 67, 67, 71, 73, 73, 71, 79, 79, 83, 79, 79, 89, 79, 79, 79, 97, 97, 101, 103, 103, 107, 109, 109, 113, 109, 109, 113, 109 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
COMMENTS
a(n) is prime for all n<=10^10 except a(13)=21.
a(n) <= 2n + 1.
a(n) = 2n + 1 if and only if 2n + 1 is prime.
a(n) = 2n - 1 if and only if 2n - 1 is a prime and 2n - 1 = 1 mod 6.
a(n) = 2n - 3 if and only if 2n - 3 is a prime and 2n - 3 = 1 mod 30.
LINKS
PROG
(Sage)
def a(n):
g=n
n+=1
while(g!=0):
g=g-gcd(n, g)
n+=1
return n
(PARI)
a(last_a) = {
local(A=last_a, B=last_a, C=2*last_a+1);
while(A>0,
D=divisors(C);
k1=10*D[2];
for(j=2, matsize(D)[2], d=D[j]; k=((A+1-B+d)/2)%d;
if(k==0, k=d); if(k<=k1, k1=k; d1=d));
if(k1-1+d1==A, B=B+1);
A = max(A-(k1-1)-d1, 0);
B = B + k1;
C = C - (d1 - 1);
);
return(B);
}
a(n)={
my(A=n, B=n, C=2*n+1);
while(A>0,
my(k1=oo, d1);
fordiv(C, d,
if(d==1, next);
my(k=((A+1-B+d)/2)%d);
if(k==0, k=d);
if(k<=k1, k1=k; d1=d)
);
A -= k1 - 1 + d1;
B += k1 + (A==0);
C -= d1 - 1;
);
B;
} \\ Charles R Greathouse IV, Nov 04 2015
CROSSREFS
A186253(n) is a^n(2) where a^n denotes the n-th composition.
Sequence in context: A082433 A082683 A084752 * A037464 A302564 A335046
KEYWORD
nonn
AUTHOR
Moritz Firsching, Aug 04 2015
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 28 14:33 EDT 2024. Contains 371254 sequences. (Running on oeis4.)