A342175 a(n) is the difference between the n-th composite number and the smallest larger composite to which it is relatively prime.
5, 19, 1, 1, 11, 13, 1, 1, 5, 7, 1, 1, 3, 1, 1, 1, 1, 5, 19, 1, 1, 1, 1, 13, 1, 1, 9, 13, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 5, 17, 1, 1, 1, 1, 19, 1, 1, 11, 5, 1, 1, 1, 1, 7, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 19, 1, 1, 11, 13, 1, 1, 5, 7, 1, 1, 3, 1
Offset: 1
Keywords
Examples
The first composite number is 4, and the smallest larger composite to which it is coprime is 9, so a(1) = 9 - 4 = 5. The second composite number is 6, and the smallest larger composite to which it is coprime is 25, so a(2) = 25 - 6 = 19.
Programs
-
Mathematica
Table[Block[{k = 1}, While[Nand[GCD[#, k] == 1, CompositeQ[# + k]], k++]; k] &@ FixedPoint[n + PrimePi@ # + 1 &, n + PrimePi@ n + 1], {n, 83}] (* Michael De Vlieger, Mar 19 2021 *)
-
PARI
lista(nn) = {forcomposite(c=1, nn, my(x=c+1); while (isprime(x) || (gcd(x,c) != 1), x++); print1(x - c, ", "););} \\ Michel Marcus, Mar 04 2021
-
Python
from sympy import isprime, gcd, composite def A342175(n): m = composite(n) k = m+1 while gcd(k,m) != 1 or isprime(k): k += 1 return k-m # Chai Wah Wu, Mar 28 2021
Comments