A347113 a(1)=1; for n > 1, a(n) is the smallest unused positive number k such that k != j and gcd(k,j) != 1, where j = a(n-1) + 1.
1, 4, 10, 22, 46, 94, 5, 2, 6, 14, 3, 8, 12, 26, 9, 15, 18, 38, 13, 7, 16, 34, 20, 24, 30, 62, 21, 11, 27, 32, 36, 74, 25, 28, 58, 118, 17, 33, 40, 82, 166, 334, 35, 39, 42, 86, 29, 44, 48, 56, 19, 45, 23, 50, 54, 60, 122, 41, 49, 52, 106, 214, 43, 55, 63, 66
Offset: 1
Keywords
Examples
a(1) = 1, by definition. a(2) = 4; it cannot be 2, because 2 = a(1) + 1, and it cannot be 3, because gcd(a(1) + 1, 3) = 1. a(3) = 10, because gcd(a(3), a(2) + 1) cannot equal 1. a(2) + 1 = 5, so a(3) must be a multiple of 5. It cannot be equal to 5, so it must be 10, the next available multiple of 5. a(4) = 22, because 22 is the smallest positive integer not equal to 11 and not coprime to 11.
Links
- Michel Marcus, Table of n, a(n) for n = 1..10000
- Chai Wah Wu, Table of n, a(n) for n = 1..10^6
- Chai Wah Wu, Graph of first million terms
- Index entries for sequences that are permutations of the integers
Crossrefs
Programs
-
Maple
b:= proc() true end: a:= proc(n) option remember; local j, k; j:= a(n-1)+1; for k from 2 do if b(k) and k<>j and igcd(k, j)>1 then b(k):= false; return k fi od end: a(1):= 1: seq(a(n), n=1..100); # Alois P. Heinz, Sep 02 2021
-
Mathematica
Block[{a = {1}, c, k, m = 2}, Do[If[IntegerQ@Log2[i], While[IntegerQ[c[m]], m++]]; Set[k, m]; While[Or[IntegerQ[c[k]], k == # + 1, GCD[k, # + 1] == 1], k++] &[a[[-1]]]; AppendTo[a, k]; Set[c[k], i], {i, 65}]; a] (* Michael De Vlieger, Aug 18 2021 *)
-
PARI
find(va, x) = {my(k=1, s=Set(va)); while ((k==x) || (gcd(k, x) == 1) || setsearch(s, k), k++); k;} lista(nn) = {my(va = vector(nn)); va[1] = 1; for (n=2, nn, va[n] = find(va, va[n-1]+1);); va;} \\ Michel Marcus, Aug 21 2021
-
Python
from math import gcd A347113_list, nset, m = [1], {1}, 2 for _ in range(100): j = A347113_list[-1]+1 k = m while k == j or gcd(k,j) == 1 or k in nset: k += 1 A347113_list.append(k) nset.add(k) while m in nset: m += 1 # Chai Wah Wu, Sep 01 2021
Extensions
Comments edited (including deletion of incorrect comments) by N. J. A. Sloane, Sep 05 2021
For the moment I am withdrawing my claim that this is a permutation of the positive integers. - N. J. A. Sloane, Sep 05 2022
Comments