A255479 Inverse permutation to A255582.
Keywords
Links
Programs
-
Haskell
import Data.List (elemIndex); import Data.Maybe (fromJust) a255479 = (+ 1) . fromJust. (`elemIndex` a255582_list) -- Reinhard Zumkeller, Mar 10 2015
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
import Data.List (elemIndex); import Data.Maybe (fromJust) a255479 = (+ 1) . fromJust. (`elemIndex` a255582_list) -- Reinhard Zumkeller, Mar 10 2015
a255480 n = a255480_list !! (n-1) a255480_list = zipWith gcd a255582_list $ drop 2 a255582_list -- Reinhard Zumkeller, Mar 10 2015
a255481 n = a255481_list !! (n-1) a255481_list = zipWith gcd a255582_list $ tail a255582_list -- Reinhard Zumkeller, Mar 10 2015
a(2) = 2, a(3) = 4 (gcd(2,4) = 2), a(4) = 6 (gcd(4,6) = 2), a(5) = 3 (gcd(6,3) = 3), a(6) = 9 (6 already used so next number which shares a factor is 9 since gcd(3,9) = 3).
import Data.List (delete, genericIndex) a064413 n = genericIndex a064413_list (n - 1) a064413_list = 1 : f 2 [2..] where ekg x zs = f zs where f (y:ys) = if gcd x y > 1 then y : ekg y (delete y zs) else f ys -- Reinhard Zumkeller, May 01 2014, Sep 17 2011
h := array(1..20000); a := array(1..10000); maxa := 300; maxn := 2*maxa; for n from 1 to maxn do h[n] := -1; od: a[1] := 2; h[2] := 1; c := 2; for n from 2 to maxa do for m from 2 to maxn do t1 := gcd(m,c); if t1 > 1 and h[m] = -1 then c := m; a[n] := c; h[c] := n; break; fi; od: od: ap := []: for n from 1 to maxa do ap := [op(ap),a[n]]; od: hp := []: for n from 2 to maxa do hp := [op(hp),h[n]]; od: convert(ap,list); convert(hp,list); # this is very crude! N:= 1000: # to get terms before the first term > N V:= Vector(N): A[1]:= 1: A[2]:= 2: V[2]:= 1: for n from 3 do S:= {seq(seq(k*p,k=1..N/p),p=numtheory:-factorset(A[n-1]))}; for s in sort(convert(S,list)) do if V[s] = 0 then A[n]:= s; break fi od; if V[s] = 1 then break fi; V[s]:= 1; od: seq(A[i],i=1..n-1); # Robert Israel, Jan 18 2016
maxN = 100; ekg = {1, 2}; unused = Range[3, maxN]; found = True; While[found, found = False; i = 0; While[ !found && i < Length[unused], i++; If[GCD[ekg[[-1]], unused[[i]]] > 1, found = True; AppendTo[ekg, unused[[i]]]; unused = Delete[unused, i]]]]; ekg (* Ayres *) ekGrapher[s_List] := Block[{m = s[[-1]], k = 3}, While[MemberQ[s, k] || GCD[m, k] == 1, k++ ]; Append[s, k]]; Nest[ekGrapher, {1, 2}, 71] (* Robert G. Wilson v, May 20 2009 *)
a1=1; a2=2; v=[1,2]; for(n=3,100,a3=if(n<0,0,t=1;while(vecmin(vector(length(v),i,abs(v[i]-t)))*(gcd(a2,t)-1)==0,t++);t);a2=a3;v=concat(v,a3);); a(n)=v[n]; /* Benoit Cloitre, Sep 23 2012 */
from math import gcd A064413_list, l, s, b = [1,2], 2, 3, {} for _ in range(10**5): i = s while True: if not i in b and gcd(i, l) > 1: A064413_list.append(i) l, b[i] = i, True while s in b: b.pop(s) s += 1 break i += 1 # Chai Wah Wu, Dec 08 2014
import Data.List (delete) a098550 n = a098550_list !! (n-1) a098550_list = 1 : 2 : 3 : f 2 3 [4..] where f u v ws = g ws where g (x:xs) = if gcd x u > 1 && gcd x v == 1 then x : f v x (delete x ws) else g xs -- Reinhard Zumkeller, Nov 21 2014
N:= 10^4: # to get a(1) to a(n) where a(n+1) is the first term > N B:= Vector(N,datatype=integer[4]): for n from 1 to 3 do A[n]:= n: od: for n from 4 do for k from 4 to N do if B[k] = 0 and igcd(k,A[n-1]) = 1 and igcd(k,A[n-2]) > 1 then A[n]:= k; B[k]:= 1; break fi od: if k > N then break fi od: seq(A[i],i=1..n-1); # Robert Israel, Nov 21 2014
f[lst_List] := Block[{k = 4}, While[ GCD[ lst[[-2]], k] == 1 || GCD[ lst[[-1]], k] > 1 || MemberQ[lst, k], k++]; Append[lst, k]]; Nest[f, {1, 2, 3}, 68] (* Robert G. Wilson v, Nov 21 2014 *) NN = Range[4, 1000]; a098550 = {1, 2, 3}; g = {-1}; While[g[[1]] != 0, g = Flatten[{FirstPosition[NN, v_ /; GCD[a098550[[-1]], v] == 1 && GCD[a098550[[-2]], v] > 1, 0]}]; If[g[[1]] != 0, d = NN[[g]]; a098550 = Flatten[Append[a098550, d[[1]]]]; NN = Delete[NN, g[[1]]]]]; Table[a098550[[n]], {n, 71}] (* L. Edson Jeffery, Jan 01 2015 *)
a(n, show=1, a=3, o=2, u=[])={n<3&&return(n); show&&print1("1, 2"); for(i=4,n, show&&print1(","a); u=setunion(u, Set(a)); while(#u>1 && u[2]==u[1]+1, u=vecextract(u,"^1")); for(k=u[1]+1, 9e9, gcd(k,o)>1||next; setsearch(u,k)&&next; gcd(k,a)==1||next; o=a; a=k; break)); a} \\ Replace "show" by "a+1==i" in the main loop to print only fixed points. - M. F. Hasler, Dec 01 2014
from math import gcd A098550_list, l1, l2, s, b = [1,2,3], 3, 2, 4, {} for _ in range(1,10**6): i = s while True: if not i in b and gcd(i,l1) == 1 and gcd(i,l2) > 1: A098550_list.append(i) l2, l1, b[i] = l1, i, 1 while s in b: b.pop(s) s += 1 break i += 1 # Chai Wah Wu, Dec 04 2014
= 1. If q=2 then a(n) is even. So we may suppose q is odd. If x is odd then a(n+1) = 2*p. If x is even then obviously a(n-1) is even. So one of a(n-1), a(n), or a(n+1) is even for every prime p. So there are infinitely many even terms. QED - N. J. A. Sloane, Aug 28 2020
A337648), that there are precisely 34 instances when q = 3 (see A337649), and q>3 happens just once, at a(5) = 35 when q=5 and p=7.
with(numtheory); N:= 10^4: # to get a(1) to a(n) where a(n+1) is the first term > N B:= Vector(N, datatype=integer[4]): for n from 1 to 2 do A[n]:= n: od: for n from 3 do for k from 3 to N do if B[k] = 0 and igcd(k, A[n-1]) > 1 and igcd(k, A[n-2]) = 1 then if nops(factorset(k) minus factorset(A[n-1])) > 0 then A[n]:= k; B[k]:= 1; break; fi; fi od: if k > N then break; fi; od: s1:=[seq(A[i], i=1..n-1)]; # N. J. A. Sloane, Sep 24 2020, based on Theorem 1 and Robert Israel's program for sequence A098550
M = 1000; A[1] = 1; A[2] = 2; Clear[B]; B[_] = 0; For[n = 3, True, n++, For[k = 3, k <= M, k++, If[B[k] == 0 && GCD[k, A[n-1]] > 1 && GCD[k, A[n-2]] == 1, If[Length[ FactorInteger[k][[All, 1]] ~Complement~ FactorInteger[A[n-1]][[All, 1]]] > 0, A[n] = k; B[k] = 1; Break[]]]]; If[k > M, Break[]]]; Array[A, n-1] (* Jean-François Alcover, Oct 20 2020, after Maple *)
from math import gcd from sympy import factorint from itertools import count, islice def agen(): # generator of terms a, seen, minan = [1, 2], {1, 2}, 3 yield from a for n in count(3): an, fset = minan, set(factorint(a[-1])) while True: if an not in seen and gcd(an, a[-1])>1 and gcd(an, a[-2])==1: if set(factorint(an)) - fset > set(): break an += 1 a.append(an); seen.add(an); yield an while minan in seen: minan += 1 print(list(islice(agen(), 70))) # Michael S. Branicky, Jan 22 2022
Comments